-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* create Pattern Refinement Models (PRMs) * refine Topologies using PRMs semi-automatically
- Loading branch information
1 parent
5c9e5ff
commit 7fb91d0
Showing
154 changed files
with
4,035 additions
and
997 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...mon/src/main/java/org/eclipse/winery/common/ids/definitions/PatternRefinementModelId.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2018 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, or the Apache Software License 2.0 | ||
* which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
*******************************************************************************/ | ||
|
||
package org.eclipse.winery.common.ids.definitions; | ||
|
||
import javax.xml.namespace.QName; | ||
|
||
import org.eclipse.winery.common.ids.Namespace; | ||
import org.eclipse.winery.common.ids.XmlId; | ||
|
||
public class PatternRefinementModelId extends DefinitionsChildId { | ||
|
||
public PatternRefinementModelId(Namespace namespace, XmlId xmlId) { | ||
super(namespace, xmlId); | ||
} | ||
|
||
public PatternRefinementModelId(String ns, String id, boolean URLencoded) { | ||
super(ns, id, URLencoded); | ||
} | ||
|
||
public PatternRefinementModelId(QName type) { | ||
super(type); | ||
} | ||
|
||
@Override | ||
public String getGroup() { | ||
return "PatternRefinementModel"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
...ubstitution/src/main/java/org/eclipse/winery/model/substitution/AbstractSubstitution.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package org.eclipse.winery.model.substitution; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import javax.xml.namespace.QName; | ||
|
||
import org.eclipse.winery.common.ids.definitions.NodeTypeId; | ||
import org.eclipse.winery.common.ids.definitions.RelationshipTypeId; | ||
import org.eclipse.winery.common.ids.definitions.ServiceTemplateId; | ||
import org.eclipse.winery.common.version.VersionUtils; | ||
import org.eclipse.winery.model.tosca.TNodeType; | ||
import org.eclipse.winery.model.tosca.TRelationshipType; | ||
import org.eclipse.winery.repository.backend.IRepository; | ||
import org.eclipse.winery.repository.backend.RepositoryFactory; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class AbstractSubstitution { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(Substitution.class); | ||
|
||
protected final IRepository repository; | ||
protected final Map<QName, TNodeType> nodeTypes = new HashMap<>(); | ||
protected final Map<QName, TRelationshipType> relationshipTypes = new HashMap<>(); | ||
|
||
protected String versionAppendix = "substituted"; | ||
|
||
public AbstractSubstitution() { | ||
this.repository = RepositoryFactory.getRepository(); | ||
this.loadDefinitions(); | ||
} | ||
|
||
private void loadDefinitions() { | ||
this.repository.getAllDefinitionsChildIds(NodeTypeId.class) | ||
.forEach(id -> | ||
this.nodeTypes.put(id.getQName(), this.repository.getElement(id)) | ||
); | ||
|
||
this.repository.getAllDefinitionsChildIds(RelationshipTypeId.class) | ||
.forEach(id -> | ||
this.relationshipTypes.put(id.getQName(), this.repository.getElement(id)) | ||
); | ||
} | ||
|
||
/** | ||
* Creates a new version of the given Service Template for the substitution. | ||
* If no new version can be created, the given Service Template will be returned. | ||
* | ||
* @param serviceTemplateId the Service Template containing abstract types to be substituted | ||
* @return the new Id of the Service Template | ||
*/ | ||
protected ServiceTemplateId getSubstitutionServiceTemplateId(ServiceTemplateId serviceTemplateId) { | ||
try { | ||
ServiceTemplateId substitutedServiceTemplateId = new ServiceTemplateId( | ||
serviceTemplateId.getNamespace().getDecoded(), | ||
VersionUtils.getNewId(serviceTemplateId, versionAppendix), | ||
false | ||
); | ||
|
||
repository.duplicate(serviceTemplateId, substitutedServiceTemplateId); | ||
LOGGER.debug("Created new Service Template version {}", substitutedServiceTemplateId); | ||
|
||
return substitutedServiceTemplateId; | ||
} catch (IOException e) { | ||
LOGGER.debug("Could not create new Service Template version during substitution", e); | ||
LOGGER.debug("Reusing existing element"); | ||
} | ||
|
||
return serviceTemplateId; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.