> ## Documentation Index
> Fetch the complete documentation index at: https://docs.activeviam.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom topic ordering

> How to override the `LOAD` operation to enforce a custom processing order for a list of topic sets extracted from the incoming DLC request.

For example, dimension tables can be loaded before the fact tables that reference them.

This can be achieved by creating a List of Sets of topics from the incoming request and then processing them in the desired order.
This can be done by overriding the existing `LOAD` operation.

#### Configuration

```java theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
@Configuration
public class CustomOperationsConfig {

	@Bean
	public DlcLoadOperation customLoadOperation(DlcLoadOperationsService dlcLoadOperationsService, INamedEntityResolverService namedEntityResolverService, DlcDescription dlcDescription) {
        return new CustomLoadOperation(dlcLoadOperationsService, namedEntityResolverService, dlcDescription);
	}
}
```

Alternatively, annotate the `CustomLoadOperation` class with `@Component` and let Spring manage the bean
creation.

#### Custom operation

```java theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
@Component
public class CustomLoadOperation extends DlcLoadOperation {

    public CustomLoadOperation(
            DlcLoadOperationsService dlcLoadOperationsService,
            NamedEntityResolverService namedEntityResolverService,
            DlcDescription dlcDescription
    ) {
        super(dlcLoadOperationsService, namedEntityResolverService, dlcDescription);
    }

    @Override
    public DlcLoadResponse process(DlcLoadRequest request) {
        Set<String> topics = dlcLoadOperationsService.resolveAliases(request);

        List<Set<String>> organizedTopics = organizeTopics(incomingTopics);

        var responses = organizedTopics.stream()
                .filter(Predicate.not(Set::isEmpty))
                .map(topicsList -> dlcLoadOperationsService.load(topicsList, request.topicOverrides(), request.scope(), request.sourceName(), request.sourceType()))
                .toList();

        return dlcLoadOperationsService.mergeResponses(responses);
    }

    List<Set<String>> organizeTopics(Set<String> topics) {
        // Custom logic to order topics
    }
}
```
