All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.finos.legend.sdlc.server.project.SimpleProjectConfiguration Maven / Gradle / Ivy

There is a newer version: 0.177.4
Show newest version
// Copyright 2020 Goldman Sachs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package org.finos.legend.sdlc.server.project;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.finos.legend.sdlc.domain.model.project.ProjectType;
import org.finos.legend.sdlc.domain.model.project.configuration.ArtifactGeneration;
import org.finos.legend.sdlc.domain.model.project.configuration.MetamodelDependency;
import org.finos.legend.sdlc.domain.model.project.configuration.PlatformConfiguration;
import org.finos.legend.sdlc.domain.model.project.configuration.ProjectConfiguration;
import org.finos.legend.sdlc.domain.model.project.configuration.ProjectDependency;
import org.finos.legend.sdlc.domain.model.project.configuration.ProjectStructureVersion;

import java.util.Collections;
import java.util.List;

public class SimpleProjectConfiguration implements ProjectConfiguration
{
    private final String projectId;
    private ProjectType projectType;
    private Boolean runDependencyTests;
    private ProjectStructureVersion projectStructureVersion;
    private List platformConfigurations;
    private String groupId;
    private String artifactId;
    private List projectDependencies;
    private List metamodelDependencies;
    private List artifactGeneration;

    private SimpleProjectConfiguration(String projectId, ProjectType projectType, ProjectStructureVersion projectStructureVersion, List platformConfigurations, String groupId, String artifactId, List projectDependencies, List metamodelDependencies, List artifactGeneration, Boolean runDependencyTests)
    {
        this.projectId = projectId;
        this.projectType = projectType;
        this.projectStructureVersion = projectStructureVersion;
        this.platformConfigurations = platformConfigurations;
        this.groupId = groupId;
        this.artifactId = artifactId;
        this.projectDependencies = (projectDependencies == null) ? Collections.emptyList() : projectDependencies;
        this.metamodelDependencies = (metamodelDependencies == null) ? Collections.emptyList() : metamodelDependencies;
        this.artifactGeneration = (artifactGeneration == null) ? Collections.emptyList() : artifactGeneration;
        this.runDependencyTests = runDependencyTests;
    }

    SimpleProjectConfiguration(ProjectConfiguration config)
    {
        this(config.getProjectId(), config.getProjectType(), config.getProjectStructureVersion(), config.getPlatformConfigurations(), config.getGroupId(), config.getArtifactId(), config.getProjectDependencies(), config.getMetamodelDependencies(), config.getArtifactGenerations(), config.getRunDependencyTests());
    }

    @Override
    public String getProjectId()
    {
        return this.projectId;
    }

    @Override
    public ProjectType getProjectType()
    {
        return this.projectType;
    }

    public void setProjectType(ProjectType projectType)
    {
        this.projectType = projectType;
    }

    @Override
    public Boolean getRunDependencyTests()
    {
        return this.runDependencyTests;
    }

    public void setRunDependencyTests(Boolean runDependencyTests)
    {
        this.runDependencyTests = runDependencyTests;
    }

    @Override
    public ProjectStructureVersion getProjectStructureVersion()
    {
        return this.projectStructureVersion;
    }

    public void setProjectStructureVersion(ProjectStructureVersion projectStructureVersion)
    {
        this.projectStructureVersion = projectStructureVersion;
    }

    public void setProjectStructureVersion(int projectStructureVersion, Integer projectStructureExtensionVersion)
    {
        setProjectStructureVersion(ProjectStructureVersion.newProjectStructureVersion(projectStructureVersion, projectStructureExtensionVersion));
    }

    @Override
    public List getPlatformConfigurations()
    {
        return this.platformConfigurations;
    }

    public void setPlatformConfigurations(List platformConfigurations)
    {
        this.platformConfigurations = platformConfigurations;
    }

    @Override
    public String getGroupId()
    {
        return this.groupId;
    }

    public void setGroupId(String groupId)
    {
        this.groupId = groupId;
    }

    @Override
    public String getArtifactId()
    {
        return this.artifactId;
    }

    public void setArtifactId(String artifactId)
    {
        this.artifactId = artifactId;
    }

    @Override
    public List getProjectDependencies()
    {
        return this.projectDependencies;
    }

    public void setProjectDependencies(List projectDependencies)
    {
        this.projectDependencies = projectDependencies;
    }

    @Override
    public List getMetamodelDependencies()
    {
        return this.metamodelDependencies;
    }

    public void setMetamodelDependencies(List metamodelDependencies)
    {
        this.metamodelDependencies = metamodelDependencies;
    }

    @Override
    public List getArtifactGenerations()
    {
        return this.artifactGeneration;
    }

    @Deprecated
    public void setArtifactGeneration(List artifactGeneration)
    {
        this.artifactGeneration = artifactGeneration;
    }

    @JsonCreator
    static SimpleProjectConfiguration newConfiguration(
            @JsonProperty("projectId") String projectId,
            @JsonProperty("projectType") ProjectType projectType,
            @JsonProperty("projectStructureVersion") @JsonDeserialize(as = SimpleProjectStructureVersion.class) ProjectStructureVersion projectStructureVersion,
            @JsonProperty("platformConfigurations") @JsonDeserialize(contentAs = SimplePlatformConfiguration.class) List platforms,
            @JsonProperty("groupId") String groupId,
            @JsonProperty("artifactId") String artifactId,
            @JsonProperty("projectDependencies") @JsonDeserialize(contentAs = SimpleProjectDependency.class) List projectDependencies,
            @JsonProperty("metamodelDependencies") @JsonDeserialize(contentAs = SimpleMetamodelDependency.class) List metamodelDependencies,
            @Deprecated @JsonProperty("artifactGenerations") @JsonDeserialize(contentAs = SimpleArtifactGeneration.class) List artifactGenerations,
            @JsonProperty("runDependencyTests") Boolean runDependenceTests)
    {
        return new SimpleProjectConfiguration(projectId, projectType, projectStructureVersion, platforms, groupId, artifactId, projectDependencies, metamodelDependencies, artifactGenerations, runDependenceTests);
    }

    @Deprecated
    static SimpleProjectConfiguration newConfiguration(String projectId, ProjectStructureVersion projectStructureVersion, String groupId, String artifactId, List projectDependencies, List metamodelDependencies, List artifactGenerations)
    {
        return newConfiguration(projectId, ProjectType.MANAGED, projectStructureVersion, null, groupId, artifactId, projectDependencies, metamodelDependencies, artifactGenerations, null);
    }

    static SimpleProjectConfiguration newConfiguration(String projectId, ProjectStructureVersion projectStructureVersion, List platforms, String groupId, String artifactId, List projectDependencies, List metamodelDependencies, List artifactGenerations)
    {
        return newConfiguration(projectId, ProjectType.MANAGED, projectStructureVersion, platforms, groupId, artifactId, projectDependencies, metamodelDependencies, artifactGenerations, null);
    }

    static SimpleProjectConfiguration newConfiguration(String projectId, ProjectStructureVersion projectStructureVersion, List platforms, String groupId, String artifactId, List projectDependencies, List metamodelDependencies, List artifactGenerations, Boolean runDependencyTests)
    {
        return newConfiguration(projectId, ProjectType.MANAGED, projectStructureVersion, platforms, groupId, artifactId, projectDependencies, metamodelDependencies, artifactGenerations, runDependencyTests);
    }

    public static class SimpleProjectStructureVersion extends ProjectStructureVersion
    {
        private final int version;
        private final Integer extensionVersion;

        @JsonCreator
        private SimpleProjectStructureVersion(@JsonProperty("version") int version, @JsonProperty("extensionVersion") Integer extensionVersion)
        {
            this.version = version;
            this.extensionVersion = extensionVersion;
        }

        @Override
        public int getVersion()
        {
            return this.version;
        }

        @Override
        public Integer getExtensionVersion()
        {
            return this.extensionVersion;
        }
    }

    public static class SimpleMetamodelDependency extends MetamodelDependency
    {
        private final String metamodel;
        private final int version;

        @JsonCreator
        private SimpleMetamodelDependency(@JsonProperty("metamodel") String metamodel, @JsonProperty("version") int version)
        {
            this.metamodel = metamodel;
            this.version = version;
        }

        @Override
        public String getMetamodel()
        {
            return this.metamodel;
        }

        @Override
        public int getVersion()
        {
            return this.version;
        }
    }

    public static class SimplePlatformConfiguration implements PlatformConfiguration
    {
        private final String name;
        private final String version;

        @JsonCreator
        private SimplePlatformConfiguration(@JsonProperty("name") String name, @JsonProperty("version") String version)
        {
            this.name = name;
            this.version = version;
        }

        @Override
        public String getName()
        {
            return this.name;
        }

        @Override
        public String getVersion()
        {
            return this.version;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy