use of org.eclipse.winery.repository.rest.resources.servicetemplates.topologytemplates.RefinementTopologyTemplateResource in project winery by eclipse.
the class TopologyFragmentRefinementModelResource method savePrmMappingTopology.
@PUT
@Path("graphicPrmTopology")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Override
public TopologyTemplateResource savePrmMappingTopology(TTopologyTemplate topologyTemplate) {
this.getTRefinementModel().resetAllMappings();
RestUtils.persist(this);
for (TRelationshipTemplate relTemplate : topologyTemplate.getRelationshipTemplates()) {
String mappingId;
// necessary for topologymodeler to create the IDs
if (relTemplate.getId().startsWith("con")) {
mappingId = relTemplate.getId().substring(relTemplate.getId().indexOf("_") + 1);
} else {
mappingId = relTemplate.getId();
}
if (relTemplate.getType().getLocalPart().startsWith("PermutationMapping")) {
this.getPermutationMappings().addMapping(new OTPermutationMapping(new OTPermutationMapping.Builder(mappingId).setDetectorElement(relTemplate.getSourceElement().getRef()).setRefinementElement(relTemplate.getTargetElement().getRef())));
}
if (relTemplate.getType().getLocalPart().startsWith("RelationshipMapping")) {
Map<String, String> propertiesMap = ((TEntityTemplate.WineryKVProperties) relTemplate.getProperties()).getKVProperties();
this.getRelationMappings().addMapping(new OTRelationMapping(new OTRelationMapping.Builder(mappingId).setDetectorElement(relTemplate.getSourceElement().getRef()).setRefinementElement(relTemplate.getTargetElement().getRef()).setDirection(OTRelationDirection.fromValue(propertiesMap.get("direction"))).setRelationType(QName.valueOf(propertiesMap.get("applicableRelationshipType"))).setValidSourceOrTarget(QName.valueOf(propertiesMap.get("validEndpointType")))));
}
if (relTemplate.getType().getLocalPart().startsWith("StayMapping")) {
this.getStayMappings().addMapping(new OTStayMapping(new OTStayMapping.Builder(mappingId).setDetectorElement(relTemplate.getSourceElement().getRef()).setRefinementElement(relTemplate.getTargetElement().getRef())));
}
if (relTemplate.getType().getLocalPart().startsWith("AttributeMapping")) {
Map<String, String> propertiesMap = ((TEntityTemplate.WineryKVProperties) relTemplate.getProperties()).getKVProperties();
this.getAttributeMappings().addMapping(new OTAttributeMapping(new OTAttributeMapping.Builder(mappingId).setDetectorElement(relTemplate.getSourceElement().getRef()).setRefinementElement(relTemplate.getTargetElement().getRef()).setType(OTAttributeMappingType.fromValue(propertiesMap.get("type"))).setDetectorProperty(propertiesMap.get("detectorProperty")).setRefinementProperty(propertiesMap.get("refinementProperty"))));
}
if (relTemplate.getType().getLocalPart().startsWith("DeploymentArtifactMapping")) {
Map<String, String> propertiesMap = ((TEntityTemplate.WineryKVProperties) relTemplate.getProperties()).getKVProperties();
this.getDeploymentArtifactMappings().addMapping(new OTDeploymentArtifactMapping(new OTDeploymentArtifactMapping.Builder(mappingId).setDetectorElement(relTemplate.getSourceElement().getRef()).setRefinementElement(relTemplate.getTargetElement().getRef()).setArtifactType(QName.valueOf(propertiesMap.get("requiredDeploymentArtifactType")))));
}
if (relTemplate.getType().getLocalPart().startsWith("BehaviorPatternMapping")) {
Map<String, String> propertiesMap = ((TEntityTemplate.WineryKVProperties) relTemplate.getProperties()).getKVProperties();
((PatternRefinementModelResource) this).getBehaviorPatternMappings().addMapping(new OTBehaviorPatternMapping(new OTBehaviorPatternMapping.Builder(mappingId).setDetectorElement(relTemplate.getSourceElement().getRef()).setRefinementElement(relTemplate.getTargetElement().getRef()).setProperty(new OTPropertyKV(propertiesMap.get("refinementProperty"), propertiesMap.get("refinementPropertyValue"))).setBehaviorPattern(propertiesMap.get("behaviorPattern"))));
}
}
return new RefinementTopologyTemplateResource(this, this.getTRefinementModel(), GRAFIC_PRM_MODEL);
}
use of org.eclipse.winery.repository.rest.resources.servicetemplates.topologytemplates.RefinementTopologyTemplateResource in project winery by eclipse.
the class TestRefinementModelResource method savePrmMappingTopology.
@PUT
@Path("graphicPrmTopology")
@Consumes(MediaType.APPLICATION_JSON)
@Override
public TopologyTemplateResource savePrmMappingTopology(TTopologyTemplate topologyTemplate) {
this.getTRefinementModel().resetAllMappings();
RestUtils.persist(this);
for (TRelationshipTemplate relTemplate : topologyTemplate.getRelationshipTemplates()) {
String mappingId;
// necessary for topologymodeler to create the IDs
if (relTemplate.getId().startsWith("con")) {
mappingId = relTemplate.getId().substring(relTemplate.getId().indexOf("_") + 1);
} else {
mappingId = relTemplate.getId();
}
if (relTemplate.getType().getLocalPart().startsWith("RelationshipMapping")) {
Map<String, String> propertiesMap = ((TEntityTemplate.WineryKVProperties) relTemplate.getProperties()).getKVProperties();
this.getRelationMappings().addMapping(new OTRelationMapping(new OTRelationMapping.Builder(mappingId).setDetectorElement(relTemplate.getSourceElement().getRef()).setRefinementElement(relTemplate.getTargetElement().getRef()).setDirection(OTRelationDirection.fromValue(propertiesMap.get("direction"))).setRelationType(QName.valueOf(propertiesMap.get("applicableRelationshipType"))).setValidSourceOrTarget(QName.valueOf(propertiesMap.get("validEndpointType")))));
}
}
return new RefinementTopologyTemplateResource(this, this.getTRefinementModel(), GRAFIC_PRM_MODEL);
}
Aggregations