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() {
     }
 
     public SimpleFactBuilder addFactfinal String factType ) {
         return addFactfactType,
                         false );
     }
 
     public SimpleFactBuilder addFactfinal String factType,
                                       final boolean isEvent ) {
         return addFactfactType,
                         isEvent,
                         TypeSource.JAVA_PROJECT );
     }
 
     public SimpleFactBuilder addFactfinal String factType,
                                       final boolean isEvent,
                                       final TypeSource typeSource ) {
         final SimpleFactBuilder builder = new SimpleFactBuilderthis,
                                                                  factType,
                                                                  isEvent,
                                                                  typeSource );
         .put(factTypebuilder);
         return builder;
     }
 
     public ProjectDataModelOracleBuilder addClassfinal Class clazz ) throws IOException {
         return addClassclazz,
                          false );
     }
 
     public ProjectDataModelOracleBuilder addClassfinal Class clazz,
                                                    final boolean isEvent ) throws IOException {
         return addClassclazz,
                          isEvent,
                          TypeSource.JAVA_PROJECT );
     }
 
     public ProjectDataModelOracleBuilder addClassfinal Class clazz,
                                                    final boolean isEvent,
                                                    final TypeSource typeSource ) throws IOException {
         final FactBuilder builder = new ClassFactBuilderthis,
                                                           clazz,
                                                           isEvent,
                                                           typeSource );
         .put(clazz.getName(), builder);
         return this;
     }
 
     public ProjectDataModelOracleBuilder addEnumfinal String factType,
                                                   final String fieldName,
                                                   final String[] values ) {
         final String qualifiedFactField = factType + "#" + fieldName;
         .put(qualifiedFactField,
                 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 ) {
        .addAll(enumLoader.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..putAll(factBuilder.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