Search in sources :

Example 11 with DatasetCreationSpec

use of co.cask.cdap.internal.dataset.DatasetCreationSpec in project cdap by caskdata.

the class ApplicationDetail method fromSpec.

public static ApplicationDetail fromSpec(ApplicationSpecification spec, @Nullable String ownerPrincipal) {
    List<ProgramRecord> programs = new ArrayList<>();
    for (ProgramSpecification programSpec : spec.getFlows().values()) {
        programs.add(new ProgramRecord(ProgramType.FLOW, spec.getName(), programSpec.getName(), programSpec.getDescription()));
    }
    for (ProgramSpecification programSpec : spec.getMapReduce().values()) {
        programs.add(new ProgramRecord(ProgramType.MAPREDUCE, spec.getName(), programSpec.getName(), programSpec.getDescription()));
    }
    for (ProgramSpecification programSpec : spec.getServices().values()) {
        programs.add(new ProgramRecord(ProgramType.SERVICE, spec.getName(), programSpec.getName(), programSpec.getDescription()));
    }
    for (ProgramSpecification programSpec : spec.getSpark().values()) {
        programs.add(new ProgramRecord(ProgramType.SPARK, spec.getName(), programSpec.getName(), programSpec.getDescription()));
    }
    for (ProgramSpecification programSpec : spec.getWorkers().values()) {
        programs.add(new ProgramRecord(ProgramType.WORKER, spec.getName(), programSpec.getName(), programSpec.getDescription()));
    }
    for (ProgramSpecification programSpec : spec.getWorkflows().values()) {
        programs.add(new ProgramRecord(ProgramType.WORKFLOW, spec.getName(), programSpec.getName(), programSpec.getDescription()));
    }
    List<StreamDetail> streams = new ArrayList<>();
    for (StreamSpecification streamSpec : spec.getStreams().values()) {
        streams.add(new StreamDetail(streamSpec.getName()));
    }
    List<DatasetDetail> datasets = new ArrayList<>();
    for (DatasetCreationSpec datasetSpec : spec.getDatasets().values()) {
        datasets.add(new DatasetDetail(datasetSpec.getInstanceName(), datasetSpec.getTypeName()));
    }
    List<PluginDetail> plugins = new ArrayList<>();
    for (Map.Entry<String, Plugin> pluginEnty : spec.getPlugins().entrySet()) {
        plugins.add(new PluginDetail(pluginEnty.getKey(), pluginEnty.getValue().getPluginClass().getName(), pluginEnty.getValue().getPluginClass().getType()));
    }
    // this is only required if there are old apps lying around that failed to get upgrading during
    // the upgrade to v3.2 for some reason. In those cases artifact id will be null until they re-deploy the app.
    // in the meantime, we don't want this api call to null pointer exception.
    ArtifactSummary summary = spec.getArtifactId() == null ? new ArtifactSummary(spec.getName(), null) : ArtifactSummary.from(spec.getArtifactId());
    return new ApplicationDetail(spec.getName(), spec.getAppVersion(), spec.getDescription(), spec.getConfiguration(), streams, datasets, programs, plugins, summary, ownerPrincipal);
}
Also used : ProgramSpecification(co.cask.cdap.api.ProgramSpecification) StreamSpecification(co.cask.cdap.api.data.stream.StreamSpecification) ArrayList(java.util.ArrayList) ArtifactSummary(co.cask.cdap.api.artifact.ArtifactSummary) DatasetCreationSpec(co.cask.cdap.internal.dataset.DatasetCreationSpec) Map(java.util.Map) Plugin(co.cask.cdap.api.plugin.Plugin)

Aggregations

DatasetCreationSpec (co.cask.cdap.internal.dataset.DatasetCreationSpec)11 WorkflowSpecification (co.cask.cdap.api.workflow.WorkflowSpecification)5 DatasetId (co.cask.cdap.proto.id.DatasetId)5 Map (java.util.Map)5 StreamSpecification (co.cask.cdap.api.data.stream.StreamSpecification)3 DatasetSpecification (co.cask.cdap.api.dataset.DatasetSpecification)2 Plugin (co.cask.cdap.api.plugin.Plugin)2 WorkflowNode (co.cask.cdap.api.workflow.WorkflowNode)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 JsonObject (com.google.gson.JsonObject)2 HashMap (java.util.HashMap)2 Path (javax.ws.rs.Path)2 ProgramSpecification (co.cask.cdap.api.ProgramSpecification)1 ArtifactId (co.cask.cdap.api.artifact.ArtifactId)1 ArtifactSummary (co.cask.cdap.api.artifact.ArtifactSummary)1 DataSetException (co.cask.cdap.api.dataset.DataSetException)1 DatasetManagementException (co.cask.cdap.api.dataset.DatasetManagementException)1 IncompatibleUpdateException (co.cask.cdap.api.dataset.IncompatibleUpdateException)1 InstanceNotFoundException (co.cask.cdap.api.dataset.InstanceNotFoundException)1 FileSet (co.cask.cdap.api.dataset.lib.FileSet)1