Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.kie.workbench.common.services.datamodel.backend.server.builder.projects;
  
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  
 import  org.drools.workbench.models.commons.backend.oracle.ProjectDataModelOracleImpl;
 import  org.drools.workbench.models.datamodel.oracle.ProjectDataModelOracle;
 import  org.drools.workbench.models.datamodel.oracle.TypeSource;
Builder for DataModelOracle
 
 public final class ProjectDataModelOracleBuilder {
 
     private ProjectDataModelOracleImpl oracle = new ProjectDataModelOracleImpl();
 
     private Map<StringFactBuilderfactTypeBuilders = new HashMap<StringFactBuilder>();
     private Map<StringString[]> factFieldEnums = new HashMap<StringString[]>();
     private List<StringpackageNames = new ArrayList<String>();
 
     private List<Stringerrors = new ArrayList<String>();
 
         return new ProjectDataModelOracleBuilder();
     }
 
     private ProjectDataModelOracleBuilder() {
     }
 
     //Used by tests
     public SimpleFactBuilder addFactfinal String factType ) {
         return addFactfactType,
                         false );
     }
 
     //Used by tests
     public SimpleFactBuilder addFactfinal String factType,
                                       final boolean isEvent ) {
         return addFactfactType,
                         isEvent,
                         TypeSource.JAVA_PROJECT );
     }
 
     //Used by tests
     public SimpleFactBuilder addFactfinal String factType,
                                       final boolean isEvent,
                                       final TypeSource typeSource ) {
         final SimpleFactBuilder builder = new SimpleFactBuilderthis,
                                                                  factType,
                                                                  isEvent,
                                                                  typeSource );
         .putfactType,
                               builder );
         return builder;
     }
 
     public ProjectDataModelOracleBuilder addClassfinal Class clazz,
                                                    final Map<StringFactBuilderdiscoveredFieldFactBuilders ) throws IOException {
         return addClassclazz,
                          discoveredFieldFactBuilders,
                          false );
     }
 
     public ProjectDataModelOracleBuilder addClassfinal Class clazz,
                                                    final Map<StringFactBuilderdiscoveredFieldFactBuilders,
                                                    final boolean isEvent ) throws IOException {
         return addClassclazz,
                          discoveredFieldFactBuilders,
                          isEvent,
                          TypeSource.JAVA_PROJECT );
     }
 
     public ProjectDataModelOracleBuilder addClassfinal Class clazz,
                                                    final Map<StringFactBuilderdiscoveredFieldFactBuilders,
                                                    final boolean isEvent,
                                                    final TypeSource typeSource ) throws IOException {
         final FactBuilder builder = new ClassFactBuilderthis,
                                                           discoveredFieldFactBuilders,
                                                           clazz,
                                                           isEvent,
                                                           typeSource );
         .putclazz.getName(),
                               builder );
         return this;
     }
 
     public ProjectDataModelOracleBuilder addEnumfinal String factType,
                                                   final String fieldName,
                                                   final String[] values ) {
         final String qualifiedFactField = factType + "#" + fieldName;
         .putqualifiedFactField,
                             values );
         return this;
     }
    public ProjectDataModelOracleBuilder addEnumfinal String enumDefinition,
                                                  final ClassLoader classLoader ) {
        parseEnumDefinitionenumDefinition,
                             classLoader );
        return this;
    }
    private void parseEnumDefinitionfinal String enumDefinition,
                                      final ClassLoader classLoader ) {
        final DataEnumLoader enumLoader = new DataEnumLoaderenumDefinition,
                                                              classLoader );
        if ( enumLoader.hasErrors() ) {
            logEnumErrorsenumLoader );
        } else {
            .putAllenumLoader.getData() );
        }
    }
    private void logEnumErrorsfinal DataEnumLoader enumLoader ) {
        .addAllenumLoader.getErrors() );
    }
    public ProjectDataModelOracle build() {
        loadFactTypes();
        loadEnums();
        loadPackageNames();
        return ;
    }
    private void loadPackageNames() {
        .addProjectPackageNames(  );
    }
    private void loadFactTypes() {
        for ( final FactBuilder factBuilder : new ArrayList<FactBuilder>( this..values() ) ) {
            this..putAllfactBuilder.getInternalBuilders() );
        }
        for ( final FactBuilder factBuilder : this..values() ) {
            factBuilder.build );
        }
    }
    private void loadEnums() {
        final Map<StringString[]> loadableEnums = new HashMap<StringString[]>();
        for ( Map.Entry<StringString[]> e : .entrySet() ) {
            final String qualifiedFactField = e.getKey();
            loadableEnums.putqualifiedFactField,
                               e.getValue() );
        }
        .addProjectJavaEnumDefinitions( loadableEnums );
    }
    public void addPackagesCollection<StringpackageNames ) {
        this..addAllpackageNames );
    }
New to GrepCode? Check out our FAQ X