Search in sources :

Example 1 with Resources

use of com.walmartlabs.concord.project.model.Resources in project concord by walmartlabs.

the class ProjectLoader method loadProject.

/**
 * Loads the project definition using the supplied path. Processes the configured
 * imports, templates and extra directories with project files.
 *
 * @param workDir       the directory containing the project files. If {@code imports} are
 *                      configured, the directory will be used as a target for repository
 *                      checkouts.
 */
public Result loadProject(Path workDir, ImportsNormalizer importsNormalizer, ImportsListener listener) throws Exception {
    workDir = workDir.normalize().toAbsolutePath();
    ProjectDefinition initial = initialLoad(workDir);
    Resources resources = initial.getResources();
    Imports imports = importsNormalizer.normalize(initial.getImports());
    List<Snapshot> snapshots = importManager.process(imports, workDir, listener);
    ProjectDefinitionBuilder b = new ProjectDefinitionBuilder(parser);
    List<String> projectPaths = resources.getProjectFilePaths();
    if (projectPaths != null) {
        for (String n : projectPaths) {
            Path p = assertLocal(workDir, workDir.resolve(n));
            if (Files.exists(p)) {
                b.addProjects(p);
            }
        }
    }
    for (String n : Constants.Files.PROJECT_ROOT_FILE_NAMES) {
        Path p = assertLocal(workDir, workDir.resolve(n));
        if (Files.exists(p)) {
            b.addProjectFile(workDir, p);
            break;
        }
    }
    List<String> definitionPaths = resources.getDefinitionPaths();
    if (definitionPaths != null) {
        for (String n : definitionPaths) {
            Path p = assertLocal(workDir, workDir.resolve(n));
            if (Files.exists(p)) {
                b.addDefinitions(p);
            }
        }
    }
    List<String> profilesPaths = resources.getProfilesPaths();
    if (profilesPaths != null) {
        for (String n : profilesPaths) {
            Path p = assertLocal(workDir, workDir.resolve(n));
            if (Files.exists(p)) {
                b.addProfiles(p);
            }
        }
    }
    ProjectDefinition pd = b.build();
    // save the normalized imports, so the exact same workDir structure
    // can be re-created later (e.g. by the Agent)
    pd = new ProjectDefinition(pd, imports);
    return new Result(snapshots, pd);
}
Also used : Path(java.nio.file.Path) Snapshot(com.walmartlabs.concord.repository.Snapshot) Resources(com.walmartlabs.concord.project.model.Resources) Imports(com.walmartlabs.concord.imports.Imports) ProjectDefinition(com.walmartlabs.concord.project.model.ProjectDefinition) FileVisitResult(java.nio.file.FileVisitResult)

Example 2 with Resources

use of com.walmartlabs.concord.project.model.Resources in project concord by walmartlabs.

the class YamlProjectConverter method convert.

public static ProjectDefinition convert(YamlProject project) throws YamlConverterException {
    Map<String, ProcessDefinition> flows = convertFlows(project.getFlows());
    Set<String> publicFlows = project.getPublicFlows();
    Map<String, FormDefinition> forms = convertForms(project.getForms());
    Map<String, Object> cfg = project.getConfiguration();
    Map<String, Profile> profiles = convertProfiles(project.getProfiles());
    List<Trigger> triggers = YamlTriggersConverter.convert(project.getTriggers());
    Imports imports = convertImports(project.getImports());
    Resources resources = convertResources(project.getResources());
    return new ProjectDefinition(flows, publicFlows, forms, cfg, profiles, triggers, imports, resources);
}
Also used : ProcessDefinition(io.takari.bpm.model.ProcessDefinition) Imports(com.walmartlabs.concord.imports.Imports) YamlImportConverter.convertImports(com.walmartlabs.concord.project.yaml.YamlImportConverter.convertImports) Profile(com.walmartlabs.concord.project.model.Profile) YamlProfile(com.walmartlabs.concord.project.yaml.model.YamlProfile) ProjectDefinition(com.walmartlabs.concord.project.model.ProjectDefinition) Trigger(com.walmartlabs.concord.project.model.Trigger) Resources(com.walmartlabs.concord.project.model.Resources) FormDefinition(io.takari.bpm.model.form.FormDefinition)

Aggregations

Imports (com.walmartlabs.concord.imports.Imports)2 ProjectDefinition (com.walmartlabs.concord.project.model.ProjectDefinition)2 Resources (com.walmartlabs.concord.project.model.Resources)2 Profile (com.walmartlabs.concord.project.model.Profile)1 Trigger (com.walmartlabs.concord.project.model.Trigger)1 YamlImportConverter.convertImports (com.walmartlabs.concord.project.yaml.YamlImportConverter.convertImports)1 YamlProfile (com.walmartlabs.concord.project.yaml.model.YamlProfile)1 Snapshot (com.walmartlabs.concord.repository.Snapshot)1 ProcessDefinition (io.takari.bpm.model.ProcessDefinition)1 FormDefinition (io.takari.bpm.model.form.FormDefinition)1 FileVisitResult (java.nio.file.FileVisitResult)1 Path (java.nio.file.Path)1