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.shared.oracle.DataType;
 import  org.guvnor.common.services.project.builder.model.TypeSource;
 import  org.kie.workbench.common.services.datamodel.model.FieldAccessorsAndMutators;
 import  org.kie.workbench.common.services.datamodel.model.ModelField;
 import  org.kie.workbench.common.services.datamodel.oracle.ProjectDataModelOracleImpl;

Base FactBuilder containing common code
 
 public abstract class BaseFactBuilder implements FactBuilder {
 
     private final ProjectDataModelOracleBuilder builder;
 
     private final String type;
     private final List<ModelField> fields = new ArrayList<ModelField>();
 
     private final boolean isCollection;
     private final boolean isEvent;
     private final TypeSource typeSource;
 
     public BaseFactBuilderfinal ProjectDataModelOracleBuilder builder,
                             final Class<?> clazz,
                             final boolean isEvent,
                             final TypeSource typeSource ) {
         this. = builder;
         this. = clazz.getName();
         this. = isCollectionclazz );
         this. = isEvent;
         this. = typeSource;
 
         addFieldnew ModelField( DataType.TYPE_THIS,
                                   ,
                                   ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS,
                                   ModelField.FIELD_ORIGIN.SELF,
                                   FieldAccessorsAndMutators.ACCESSOR,
                                   DataType.TYPE_THIS ) );
     }
 
     public BaseFactBuilderfinal ProjectDataModelOracleBuilder builder,
                             final String type,
                             final boolean isCollection,
                             final boolean isEvent,
                             final TypeSource typeSource ) {
         this. = builder;
         this. = type;
         this. = isCollection;
         this. = isEvent;
         this. = typeSource;
 
         addFieldnew ModelField( DataType.TYPE_THIS,
                                   type,
                                   ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS,
                                   ModelField.FIELD_ORIGIN.SELF,
                                   FieldAccessorsAndMutators.ACCESSOR,
                                   DataType.TYPE_THIS ) );
     }
 
     private boolean isCollectionfinal Class<?> clazz ) {
         return ( clazz != null && Collection.class.isAssignableFromclazz ) );
     }
 
     public String getType() {
         return ;
     }
 
     protected String getTypefinal Class<?> clazz ) {
         return clazz.getName();
     }
 
     protected FactBuilder addFieldfinal ModelField field ) {
         this..add( field );
         return this;
     }
 
     @Override
     public ProjectDataModelOracleBuilder end() {
         return ;
     }
 
     @Override
     public void buildfinal ProjectDataModelOracleImpl oracle ) {
         oracle.addFactsAndFields( buildFactsAndFields() );
         oracle.addCollectionTypes( buildCollectionTypes() );
         oracle.addEventTypes( buildEventTypes() );
         oracle.addTypeSources( buildTypeSources() );
     }
 
         return this.;
     }
 
    private Map<String, ModelField[]> buildFactsAndFields() {
        final Map<String, ModelField[]> loadableFactsAndFields = new HashMap<String, ModelField[]>();
        final ModelField[] loadableFields = new ModelField[ .size() ];
        .toArray( loadableFields );
        loadableFactsAndFields.put( ,
                                    loadableFields );
        return loadableFactsAndFields;
    }
    private Map<StringBooleanbuildCollectionTypes() {
        final Map<StringBooleanloadableCollectionTypes = new HashMap<StringBoolean>();
        loadableCollectionTypes.put,
                                      );
        return loadableCollectionTypes;
    }
    private Map<StringBooleanbuildEventTypes() {
        final Map<StringBooleanloadableEventTypes = new HashMap<StringBoolean>();
        loadableEventTypes.put,
                                 );
        return loadableEventTypes;
    }
    private Map<String, TypeSource> buildTypeSources() {
        final Map<String, TypeSource> loadableTypeSources = new HashMap<String, TypeSource>();
        loadableTypeSources.put( ,
                                  );
        return loadableTypeSources;
    }
New to GrepCode? Check out our FAQ X