All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.camunda.service.transformers.ServiceTransformers Maven / Gradle / Ivy

There is a newer version: 8.7.0-alpha2
Show newest version
/*
 * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under
 * one or more contributor license agreements. See the NOTICE file distributed
 * with this work for additional information regarding copyright ownership.
 * Licensed under the Camunda License 1.0. You may not use this file
 * except in compliance with the Camunda License 1.0.
 */
package io.camunda.service.transformers;

import io.camunda.search.clients.core.SearchQueryRequest;
import io.camunda.search.clients.query.SearchQuery;
import io.camunda.service.search.filter.ComparableValueFilter;
import io.camunda.service.search.filter.DateValueFilter;
import io.camunda.service.search.filter.DecisionDefinitionFilter;
import io.camunda.service.search.filter.DecisionRequirementsFilter;
import io.camunda.service.search.filter.FilterBase;
import io.camunda.service.search.filter.ProcessInstanceFilter;
import io.camunda.service.search.filter.UserFilter;
import io.camunda.service.search.filter.UserTaskFilter;
import io.camunda.service.search.filter.VariableFilter;
import io.camunda.service.search.filter.VariableValueFilter;
import io.camunda.service.search.query.DecisionDefinitionQuery;
import io.camunda.service.search.query.DecisionRequirementsQuery;
import io.camunda.service.search.query.ProcessInstanceQuery;
import io.camunda.service.search.query.SearchQueryResult;
import io.camunda.service.search.query.TypedSearchQuery;
import io.camunda.service.search.query.UserQuery;
import io.camunda.service.search.query.UserTaskQuery;
import io.camunda.service.search.query.VariableQuery;
import io.camunda.service.search.sort.DecisionDefinitionSort;
import io.camunda.service.search.sort.DecisionRequirementsSort;
import io.camunda.service.search.sort.ProcessInstanceSort;
import io.camunda.service.search.sort.SortOption;
import io.camunda.service.search.sort.UserSort;
import io.camunda.service.search.sort.UserTaskSort;
import io.camunda.service.search.sort.VariableSort;
import io.camunda.service.security.auth.Authentication;
import io.camunda.service.transformers.filter.AuthenticationTransformer;
import io.camunda.service.transformers.filter.ComparableValueFilterTransformer;
import io.camunda.service.transformers.filter.DateValueFilterTransformer;
import io.camunda.service.transformers.filter.DecisionDefinitionFilterTransformer;
import io.camunda.service.transformers.filter.DecisionRequirementsFilterTransformer;
import io.camunda.service.transformers.filter.FilterTransformer;
import io.camunda.service.transformers.filter.ProcessInstanceFilterTransformer;
import io.camunda.service.transformers.filter.UserFilterTransformer;
import io.camunda.service.transformers.filter.UserTaskFilterTransformer;
import io.camunda.service.transformers.filter.VariableFilterTransformer;
import io.camunda.service.transformers.filter.VariableValueFilterTransformer;
import io.camunda.service.transformers.query.SearchQueryResultTransformer;
import io.camunda.service.transformers.query.TypedSearchQueryTransformer;
import io.camunda.service.transformers.sort.FieldSortingTransformer;
import java.util.HashMap;
import java.util.Map;

public final class ServiceTransformers {

  private final Map, ServiceTransformer> transformers;

  public ServiceTransformers() {
    transformers = new HashMap<>();
    initializeTransformers(this);
  }

  public 
      TypedSearchQueryTransformer getTypedSearchQueryTransformer(final Class cls) {
    final ServiceTransformer, SearchQueryRequest> transformer =
        getTransformer(cls);
    return (TypedSearchQueryTransformer) transformer;
  }

  public  FilterTransformer getFilterTransformer(final Class cls) {
    final ServiceTransformer transformer = getTransformer(cls);
    return (FilterTransformer) transformer;
  }

  public  ServiceTransformer getTransformer(final Class cls) {
    return (ServiceTransformer) transformers.get(cls);
  }

  private void put(final Class cls, final ServiceTransformer mapper) {
    transformers.put(cls, mapper);
  }

  public static void initializeTransformers(final ServiceTransformers mappers) {
    // query -> request
    mappers.put(
        ProcessInstanceQuery.class,
        new TypedSearchQueryTransformer(mappers));
    mappers.put(
        UserTaskQuery.class,
        new TypedSearchQueryTransformer(mappers));
    mappers.put(
        VariableQuery.class,
        new TypedSearchQueryTransformer(mappers));
    mappers.put(
        DecisionDefinitionQuery.class,
        new TypedSearchQueryTransformer(mappers));
    mappers.put(
        DecisionRequirementsQuery.class,
        new TypedSearchQueryTransformer(
            mappers));
    mappers.put(UserQuery.class, new TypedSearchQueryTransformer(mappers));

    // search query response -> search query result
    mappers.put(SearchQueryResult.class, new SearchQueryResultTransformer());

    // sorting -> search sort options
    mappers.put(FieldSortingTransformer.class, new FieldSortingTransformer());

    // filters -> search query
    mappers.put(Authentication.class, new AuthenticationTransformer());
    mappers.put(ProcessInstanceFilter.class, new ProcessInstanceFilterTransformer(mappers));
    mappers.put(UserTaskFilter.class, new UserTaskFilterTransformer(mappers));
    mappers.put(VariableValueFilter.class, new VariableValueFilterTransformer());
    mappers.put(DateValueFilter.class, new DateValueFilterTransformer());
    mappers.put(
        VariableFilter.class,
        new VariableFilterTransformer(mappers, new VariableValueFilterTransformer()));
    mappers.put(DecisionDefinitionFilter.class, new DecisionDefinitionFilterTransformer());
    mappers.put(DecisionRequirementsFilter.class, new DecisionRequirementsFilterTransformer());
    mappers.put(UserFilter.class, new UserFilterTransformer());
    mappers.put(ComparableValueFilter.class, new ComparableValueFilterTransformer());
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy