use of org.eclipse.winery.repository.backend.IRepository in project winery by eclipse.
the class TenantRepository method initTenantRepository.
public IRepository initTenantRepository(String tenantName) throws GitAPIException, IOException {
FileBasedRepositoryConfiguration fileBasedConfig = new FileBasedRepositoryConfiguration(repositoryRoot.resolve(tenantName));
IRepository tenantRepo = this.createRepo(new GitBasedRepositoryConfiguration(false, fileBasedConfig));
repositories.put(tenantName, tenantRepo);
return tenantRepo;
}
use of org.eclipse.winery.repository.backend.IRepository in project winery by eclipse.
the class WeaveGoHandler method handleNode.
@Override
public Set<String> handleNode(TNodeTemplate dockerContainer, TTopologyTemplate topologyTemplate, String imageId) {
Set<String> discoveredNodeIds = new HashSet<>();
IRepository repository = RepositoryFactory.getRepository();
dockerContainer.setType(QNAME_ALPINE_CONTAINER);
TNodeType goAppType = repository.getElement(new NodeTypeId(QNAME_GO_APP));
TNodeTemplate goApp = ModelUtilities.instantiateNodeTemplate(goAppType);
goApp.setName(dockerContainer.getName());
topologyTemplate.addNodeTemplate(goApp);
ModelUtilities.createRelationshipTemplateAndAddToTopology(goApp, dockerContainer, ToscaBaseTypes.hostedOnRelationshipType, topologyTemplate);
discoveredNodeIds.add(dockerContainer.getId());
discoveredNodeIds.add(goApp.getId());
return discoveredNodeIds;
}
use of org.eclipse.winery.repository.backend.IRepository in project winery by eclipse.
the class PlacementUtils method completeModel.
/**
* Completes the model based on the defined provider assignments and returns a completed ServiceTemplate if the
* completion was successful. Otherwise, the ServiceTemplate with cleaned location and provider assignments is
* returned. Additionally, the providers that led to the error are added to the black lists of the components.
*
* @param serviceTemplateId the ID of the ServiceTemplate to complete
* @param topology the incomplete TopologyTemplate to complete
* @param blackList the black list containing the NodeTemplates with the providers that are not usable for
* them
* @return the completed TopologyTemplate if completion is successful, the cleared and blacklisted TopologyTemplate
* otherwise
*/
private static TTopologyTemplate completeModel(ServiceTemplateId serviceTemplateId, TTopologyTemplate topology, Map<String, List<String>> blackList) {
Splitting splitting = new Splitting();
IRepository repo = RepositoryFactory.getRepository();
try {
// create new temporary ServiceTemplate as working copy
ServiceTemplateId placementId = new ServiceTemplateId(serviceTemplateId.getNamespace().getDecoded(), VersionSupport.getNewComponentVersionId(serviceTemplateId, "placement"), false);
repo.forceDelete(placementId);
TServiceTemplate placementServiceTemplate = new TServiceTemplate();
placementServiceTemplate.setTargetNamespace(serviceTemplateId.getNamespace().getDecoded());
placementServiceTemplate.setTopologyTemplate(topology);
placementServiceTemplate.setName(placementId.getXmlId().getDecoded());
placementServiceTemplate.setId(placementServiceTemplate.getName());
// resolve open requirements until the topology is completed
while (topology != null && !splitting.getOpenRequirements(topology).isEmpty()) {
// add a target label to the topology based on the provider and location assignment
assignNodesToTargetLabels(topology);
placementServiceTemplate.setTopologyTemplate(topology);
repo.setElement(placementId, placementServiceTemplate);
// complete next level of requirements
ServiceTemplateId newServiceTemplateId = splitting.matchTopologyOfServiceTemplate(placementId);
topology = repo.getElement(newServiceTemplateId).getTopologyTemplate();
// delete intermediate result to avoid cluttering
repo.forceDelete(placementId);
placementId = newServiceTemplateId;
}
repo.forceDelete(placementId);
// returned completed topology
return topology;
} catch (Exception e) {
LOGGER.debug("Exception while completing topology: {}", e.getMessage());
return topology;
}
}
use of org.eclipse.winery.repository.backend.IRepository in project winery by eclipse.
the class EdmmResource method getOneToOneMap.
@GET
@Path("one-to-one-map")
@Produces(MediaType.APPLICATION_JSON)
public Response getOneToOneMap() {
IRepository repository = RepositoryFactory.getRepository();
EdmmManager edmmManager = EdmmManager.forRepository(repository);
Map<QName, EdmmType> oneToOneMap = edmmManager.getOneToOneMap();
Map<String, String> reverseOneToOneMap = new HashMap<>();
for (Map.Entry<QName, EdmmType> entry : oneToOneMap.entrySet()) {
EdmmType edmmType = entry.getValue();
reverseOneToOneMap.put(edmmType.getValue(), entry.getKey().getLocalPart());
}
return Response.ok().type(MediaType.APPLICATION_JSON).entity(reverseOneToOneMap).build();
}
use of org.eclipse.winery.repository.backend.IRepository in project winery by eclipse.
the class GenericArtifactsResource method findInterface.
private Optional<TInterface> findInterface(EntityTypeId id, String interfaceName) {
TInterface i;
List<TInterface> interfaces = new ArrayList<>();
IRepository repository = RepositoryFactory.getRepository();
if (this.res instanceof NodeTypeImplementationResource || this.res instanceof NodeTypeImplementationsResource) {
TNodeType nodeType = repository.getElement((NodeTypeId) id);
if (nodeType.getInterfaces() != null) {
interfaces.addAll(nodeType.getInterfaces());
}
} else if (this.res instanceof RelationshipTypeImplementationResource || this.res instanceof RelationshipTypeImplementationsResource) {
TRelationshipType relationshipType = repository.getElement((RelationshipTypeId) id);
if (relationshipType.getSourceInterfaces() != null) {
interfaces.addAll(relationshipType.getSourceInterfaces());
}
if (relationshipType.getTargetInterfaces() != null) {
interfaces.addAll(relationshipType.getTargetInterfaces());
}
if (relationshipType.getInterfaces() != null) {
interfaces.addAll(relationshipType.getInterfaces());
}
}
Iterator<TInterface> it = interfaces.iterator();
do {
i = it.next();
if (i.getName().equals(interfaceName)) {
return Optional.of(i);
}
} while (it.hasNext());
return Optional.empty();
}
Aggregations