private Map<String, TArtifactDefinition> refactorDeploymentArtifacts(Map<String, TArtifactDefinition> map) { return map.entrySet().stream() // Filter for deployment artifacts .filter(entry -> Objects.nonNull(entry.getValue()) && !referenceVisitor.getTypes(entry.getValue().getType(), "TArtifactType").getNames().contains(Defaults.IMPLEMENTATION_ARTIFACTS)) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); }
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof TArtifactDefinition)) return false; TArtifactDefinition that = (TArtifactDefinition) o; return Objects.equals(getType(), that.getType()) && Objects.equals(getRepository(), that.getRepository()) && Objects.equals(getDescription(), that.getDescription()) && Objects.equals(getDeployPath(), that.getDeployPath()) && Objects.equals(getFiles(), that.getFiles()) && Objects.equals(getProperties(), that.getProperties()); }
/** * Converts TOSCA YAML ArtifactDefinitions to TOSCA XML DeploymentArtifacts * * @param artifactDefinitionMap map of TOSCA YAML ArtifactDefinitions * @return TOSCA XML DeploymentArtifacts */ private TDeploymentArtifacts convertDeploymentArtifacts(@NonNull Map<String, TArtifactDefinition> artifactDefinitionMap) { if (artifactDefinitionMap.isEmpty()) return null; return new TDeploymentArtifacts.Builder(artifactDefinitionMap.entrySet().stream() .filter(Objects::nonNull) .map(entry -> { TArtifactTemplate artifactTemplate = convert(entry.getValue(), entry.getKey()); this.artifactTemplates.put(artifactTemplate.getId(), artifactTemplate); return new TDeploymentArtifact.Builder(entry.getKey(), entry.getValue().getType()) .setArtifactRef(new QName(artifactTemplate.getId())) .build(); }) .collect(Collectors.toList())) .build(); }
/** * Converts TOSCA YAML ArtifactDefinitions to TOSCA XML ImplementationArtifacts * * @param artifactDefinitionMap map of TOSCA YAML ArtifactDefinitions * @return TOSCA XML ImplementationArtifacts */ private TImplementationArtifacts convertImplementationArtifact(@NonNull Map<String, TArtifactDefinition> artifactDefinitionMap) { if (artifactDefinitionMap.isEmpty()) return null; return new TImplementationArtifacts.Builder(artifactDefinitionMap.entrySet().stream() .filter(entry -> Objects.nonNull(entry) && Objects.nonNull(entry.getValue())) .map(entry -> { TArtifactTemplate artifactTemplate = convert(entry.getValue(), entry.getKey()); this.artifactTemplates.put(artifactTemplate.getId(), artifactTemplate); return new TImplementationArtifacts.ImplementationArtifact.Builder(entry.getValue().getType()) .setName(entry.getKey()) .setArtifactRef(new QName(artifactTemplate.getId())) .setInterfaceName(convertInterfaceName(entry.getValue())) .setOperationName(convertOperationName(entry.getValue())) .build(); }) .collect(Collectors.toList())) .build(); }
/** * Converts a TOSCA YAML ArtifactDefinition to a TOSCA XML ArtifactTemplate * * @param node TOSCA YAML ArtifactDefinition * @return TOSCA XML ArtifactTemplate */ @NonNull private TArtifactTemplate convert(TArtifactDefinition node, String id) { return new TArtifactTemplate.Builder(id, node.getType()) .addArtifactReferences(node.getFiles().stream() .filter(Objects::nonNull) // TODO change filepath .map(file -> new TArtifactReference.Builder(file).build()) .collect(Collectors.toList()) ) .setProperties(convertPropertyAssignments(node.getProperties(), getPropertyTypeName(node.getType()))) .build(); }
@Override public int hashCode() { return Objects.hash(getType(), getRepository(), getDescription(), getDeployPath(), getFiles(), getProperties()); }
&& !referenceVisitor.getTypes(entry.getValue().getType(), "TArtifactType").getNames().contains(Defaults.DEPLOYMENT_ARTIFACTS)) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)));
public Builder(TArtifactDefinition artifactDefinition) { this.type = artifactDefinition.getType(); this.files = artifactDefinition.getFiles(); this.repository = artifactDefinition.getRepository(); this.description = artifactDefinition.getDescription(); this.deployPath = artifactDefinition.getDeployPath(); this.properties = artifactDefinition.getProperties(); }
@Override public String toString() { return "TArtifactDefinition{" + "type=" + getType() + ", repository='" + getRepository() + '\'' + ", description='" + getDescription() + '\'' + ", deployPath='" + getDeployPath() + '\'' + ", files=" + getFiles() + ", properties=" + getProperties() + '}'; }
public Printer visit(TArtifactDefinition node, Parameter parameter) { return new Printer(parameter.getIndent()) .printKeyValue("type", node.getType()) .printKeyValue("repository", node.getRepository()) .printKeyValue("description", node.getDescription()) .printKeyValue("deploy_path", node.getDeployPath()) .printKeyValue("file", node.getFile()) .printKeyValue("files", node.getFiles()); }