Search in sources :

Example 6 with StepFieldOperations

use of org.pentaho.metaverse.api.StepFieldOperations in project pdi-dataservice-server-plugin by pentaho.

the class AutoParameterGenerationService method generateOptimizationList.

private List<PushDownOptimizationMeta> generateOptimizationList(SourceLineageMap sourceLineageMap) {
    Map<String, Set<List<StepFieldOperations>>> inputSteps = Multimaps.asMap(sourceLineageMap);
    List<PushDownOptimizationMeta> optimizationList = Lists.newArrayListWithExpectedSize(inputSteps.size());
    for (Map.Entry<String, Set<List<StepFieldOperations>>> inputStepLineage : inputSteps.entrySet()) {
        String inputStep = inputStepLineage.getKey();
        Set<List<StepFieldOperations>> lineageSet = inputStepLineage.getValue();
        PushDownOptimizationMeta pushDownOptimizationMeta = new PushDownOptimizationMeta();
        ParameterGeneration parameterGeneration = serviceProvider.createPushDown();
        pushDownOptimizationMeta.setName(MessageFormat.format("Parameter Generator: {0}", inputStep));
        pushDownOptimizationMeta.setStepName(inputStep);
        pushDownOptimizationMeta.setType(parameterGeneration);
        parameterGeneration.setParameterName("DATA_SERVICE_QUERY_" + inputStep.replaceAll("\\s", "_").toUpperCase());
        for (List<StepFieldOperations> fieldLineage : lineageSet) {
            StepFieldOperations origin = fieldLineage.get(0);
            StepFieldOperations last = Iterables.getLast(fieldLineage);
            parameterGeneration.createFieldMapping(last.getFieldName(), origin.getFieldName());
        }
        optimizationList.add(pushDownOptimizationMeta);
    }
    return optimizationList;
}
Also used : HashSet(java.util.HashSet) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) StepFieldOperations(org.pentaho.metaverse.api.StepFieldOperations) PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta) List(java.util.List) Map(java.util.Map)

Aggregations

Set (java.util.Set)6 StepFieldOperations (org.pentaho.metaverse.api.StepFieldOperations)6 ImmutableSet (com.google.common.collect.ImmutableSet)4 HashSet (java.util.HashSet)3 List (java.util.List)3 Test (org.junit.Test)3 PushDownOptimizationMeta (org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta)3 Matchers.anyString (org.mockito.Matchers.anyString)2 StepMeta (org.pentaho.di.trans.step.StepMeta)2 Operations (org.pentaho.metaverse.api.model.Operations)2 Graph (com.tinkerpop.blueprints.Graph)1 Vertex (com.tinkerpop.blueprints.Vertex)1 GremlinPipeline (com.tinkerpop.gremlin.java.GremlinPipeline)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 LogChannelInterface (org.pentaho.di.core.logging.LogChannelInterface)1 TransMeta (org.pentaho.di.trans.TransMeta)1 MetaverseException (org.pentaho.metaverse.api.MetaverseException)1 IOperation (org.pentaho.metaverse.api.model.IOperation)1