Search in sources :

Example 1 with ComponentConfig

use of org.apache.ofbiz.base.component.ComponentConfig in project ofbiz-framework by apache.

the class LabelManagerFactory method loadComponentNames.

protected static void loadComponentNames() {
    componentNamesFound = new TreeSet<String>();
    Collection<ComponentConfig> componentConfigs = ComponentConfig.getAllComponents();
    for (ComponentConfig componentConfig : componentConfigs) {
        componentNamesFound.add(componentConfig.getComponentName());
    }
}
Also used : ComponentConfig(org.apache.ofbiz.base.component.ComponentConfig)

Example 2 with ComponentConfig

use of org.apache.ofbiz.base.component.ComponentConfig in project ofbiz-framework by apache.

the class UtilJavaParse method findRealPathAndFileForClass.

public static String findRealPathAndFileForClass(String fullyQualifiedClassName) {
    // search through the component directories, in the src directory for each, using the class path as the path within it
    String sourceSubPath = fullyQualifiedClassName.substring(0, fullyQualifiedClassName.lastIndexOf(".")).replace('.', File.separatorChar);
    String classFileName = fullyQualifiedClassName.substring(fullyQualifiedClassName.lastIndexOf(".") + 1) + ".java";
    Collection<ComponentConfig> allComponentConfigs = ComponentConfig.getAllComponents();
    for (ComponentConfig cc : allComponentConfigs) {
        String rootDirectory = cc.getRootLocation();
        if (!rootDirectory.endsWith(File.separatorChar + "")) {
            rootDirectory += File.separatorChar;
        }
        rootDirectory += "src" + File.separatorChar;
        File rootDirFile = new File(rootDirectory);
        if (!rootDirFile.exists()) {
            // no src directory, move along
            continue;
        }
        String classDir = rootDirectory + sourceSubPath;
        File classDirFile = new File(classDir);
        if (!classDirFile.exists()) {
            // no src class sub-directory, move along
            continue;
        }
        String fullPathAndFile = classDir + File.separatorChar + classFileName;
        File classFile = new File(fullPathAndFile);
        if (classFile.exists()) {
            if (Debug.verboseOn()) {
                Debug.logVerbose("In findRealPathAndFileForClass for [" + fullyQualifiedClassName + "]: [" + fullPathAndFile + "]", module);
            }
            return fullPathAndFile;
        }
    }
    return null;
}
Also used : ComponentConfig(org.apache.ofbiz.base.component.ComponentConfig) File(java.io.File)

Example 3 with ComponentConfig

use of org.apache.ofbiz.base.component.ComponentConfig in project ofbiz-framework by apache.

the class ArtifactInfoFactory method prepareAll.

public void prepareAll() throws GeneralException {
    Debug.logInfo("Loading artifact info objects...", module);
    List<Future<Void>> futures = new ArrayList<Future<Void>>();
    Set<String> entityNames = this.getEntityModelReader().getEntityNames();
    for (String entityName : entityNames) {
        this.getEntityArtifactInfo(entityName);
    }
    Set<String> serviceNames = this.getDispatchContext().getAllServiceNames();
    for (String serviceName : serviceNames) {
        futures.add(ExecutionPool.GLOBAL_FORK_JOIN.submit(prepareTaskForServiceAnalysis(serviceName)));
    }
    // how to get all Service ECAs to prepare? don't worry about it, will be populated from service load, ie all ECAs for each service
    Collection<ComponentConfig> componentConfigs = ComponentConfig.getAllComponents();
    ExecutionPool.getAllFutures(futures);
    futures = new ArrayList<Future<Void>>();
    for (ComponentConfig componentConfig : componentConfigs) {
        futures.add(ExecutionPool.GLOBAL_FORK_JOIN.submit(prepareTaskForComponentAnalysis(componentConfig)));
    }
    ExecutionPool.getAllFutures(futures);
    Debug.logInfo("Artifact info objects loaded.", module);
}
Also used : ComponentConfig(org.apache.ofbiz.base.component.ComponentConfig) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future)

Example 4 with ComponentConfig

use of org.apache.ofbiz.base.component.ComponentConfig in project ofbiz-framework by apache.

the class EntityDataLoadContainer method createOrUpdateComponentEntities.

private void createOrUpdateComponentEntities(Delegator baseDelegator, Collection<ComponentConfig> allComponents) {
    for (ComponentConfig config : allComponents) {
        GenericValue componentEntry = baseDelegator.makeValue("Component");
        componentEntry.set("componentName", config.getComponentName());
        componentEntry.set("rootLocation", config.getRootLocation());
        try {
            GenericValue componentCheck = EntityQuery.use(baseDelegator).from("Component").where("componentName", config.getComponentName()).queryOne();
            if (UtilValidate.isEmpty(componentCheck)) {
                componentEntry.create();
            } else {
                componentEntry.store();
            }
        } catch (GenericEntityException e) {
            Debug.logError(e.getMessage(), module);
        }
    }
}
Also used : GenericValue(org.apache.ofbiz.entity.GenericValue) ComponentConfig(org.apache.ofbiz.base.component.ComponentConfig) GenericEntityException(org.apache.ofbiz.entity.GenericEntityException)

Example 5 with ComponentConfig

use of org.apache.ofbiz.base.component.ComponentConfig in project ofbiz-framework by apache.

the class EntityDataLoadContainer method loadDataForDelegator.

private void loadDataForDelegator(Map<String, String> loadDataProps, Configuration configuration, Property delegatorNameProp, String overrideDelegator) throws ContainerException {
    // prepare command line properties passed by user
    boolean createPks = isPropertySet(loadDataProps, CREATE_P_KEYS);
    boolean dropPks = isPropertySet(loadDataProps, DROP_P_KEYS);
    boolean createConstraints = isPropertySet(loadDataProps, CREATE_CONSTRAINTS);
    boolean dropConstraints = isPropertySet(loadDataProps, DROP_CONSTRAINTS);
    boolean repairColumns = isPropertySet(loadDataProps, REPAIR_COLUMNS);
    String entityGroup = getEntityGroupNameFromConfig(configuration, loadDataProps.get(DATA_GROUP));
    // prepare objects needed for the data loading logic
    Delegator delegator = getDelegator(delegatorNameProp, overrideDelegator);
    Delegator baseDelegator = getBaseDelegator(delegator);
    GenericHelperInfo helperInfo = getHelperInfo(delegator, entityGroup);
    DatabaseUtil dbUtil = new DatabaseUtil(helperInfo);
    Map<String, ModelEntity> modelEntities = getModelEntities(delegator, entityGroup);
    TreeSet<String> modelEntityNames = new TreeSet<String>(modelEntities.keySet());
    Collection<ComponentConfig> allComponents = ComponentConfig.getAllComponents();
    // data loading logic starts here
    createOrUpdateComponentEntities(baseDelegator, allComponents);
    if (dropConstraints) {
        dropDbConstraints(dbUtil, modelEntities, modelEntityNames);
    }
    if (dropPks) {
        dropPrimaryKeys(dbUtil, modelEntities, modelEntityNames);
    }
    if (repairColumns) {
        repairDbColumns(dbUtil, modelEntities);
    }
    loadData(delegator, baseDelegator, allComponents, helperInfo, loadDataProps);
    if (createPks) {
        createPrimaryKeys(dbUtil, modelEntities, modelEntityNames);
    }
    if (createConstraints) {
        createDbConstraints(dbUtil, modelEntities, modelEntityNames);
    }
}
Also used : Delegator(org.apache.ofbiz.entity.Delegator) TreeSet(java.util.TreeSet) ComponentConfig(org.apache.ofbiz.base.component.ComponentConfig) GenericHelperInfo(org.apache.ofbiz.entity.datasource.GenericHelperInfo) ModelEntity(org.apache.ofbiz.entity.model.ModelEntity) DatabaseUtil(org.apache.ofbiz.entity.jdbc.DatabaseUtil)

Aggregations

ComponentConfig (org.apache.ofbiz.base.component.ComponentConfig)7 File (java.io.File)3 ArrayList (java.util.ArrayList)1 TreeSet (java.util.TreeSet)1 Future (java.util.concurrent.Future)1 Classpath (org.apache.ofbiz.base.start.Classpath)1 Delegator (org.apache.ofbiz.entity.Delegator)1 GenericEntityException (org.apache.ofbiz.entity.GenericEntityException)1 GenericValue (org.apache.ofbiz.entity.GenericValue)1 GenericHelperInfo (org.apache.ofbiz.entity.datasource.GenericHelperInfo)1 DatabaseUtil (org.apache.ofbiz.entity.jdbc.DatabaseUtil)1 ModelEntity (org.apache.ofbiz.entity.model.ModelEntity)1