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.*;
  
  import  org.drools.workbench.models.commons.shared.oracle.model.TypeSource;
  import  org.drools.workbench.models.commons.shared.oracle.ProjectDataModelOracle;
  import  org.drools.workbench.models.datamodel.oracle.ProjectDataModelOracleImpl;
Builder for DataModelOracle
 
 public final class ProjectDataModelOracleBuilder {
 
     private ProjectDataModelOracleImpl oracle = new ProjectDataModelOracleImpl();
 
     private List<FactBuilderfactTypeBuilders = new ArrayList<FactBuilder>();
     private Map<StringString[]> factFieldEnums = new HashMap<StringString[]>();
     private Map<String,Collection<String>> ruleNames = new HashMap<StringCollection<String>>();
     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 );
         .addbuilder );
         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 );
         .addbuilder );
         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 ) {
         parseEnumDefinitionenumDefinition );
         return this;
     }
 
     private void parseEnumDefinitionfinal String enumDefinition ) {
         final DataEnumLoader enumLoader = new DataEnumLoaderenumDefinition );
         if ( enumLoader.hasErrors() ) {
             logEnumErrorsenumLoader );
         } else {
             .putAllenumLoader.getData() );
         }
     }
    private void logEnumErrorsfinal DataEnumLoader enumLoader ) {
        .addAllenumLoader.getErrors() );
    }
    public ProjectDataModelOracle build() {
        loadFactTypes();
        loadEnums();
        loadRuleNames();
        loadPackageNames();
        return ;
    }
    private void loadRuleNames() {
        for (String packageName : .keySet()) {
            .addRuleNames(packageName.get(packageName));
        }
    }
    private void loadPackageNames() {
        .addPackageNames();
    }
    private void loadFactTypes() {
        for ( final FactBuilder factBuilder : this. ) {
            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() );
        }
        .addEnumDefinitions( loadableEnums );
    }
    public void addRuleNames(String packageNameCollection<StringruleNames) {
        this..put(packageNameruleNames);
    }
    public void addPackages(Collection<StringpackageNames) {
        this..addAll(packageNames);
    }
New to GrepCode? Check out our FAQ X