Search in sources :

Example 1 with RelationshipTypeImplementationsResource

use of org.eclipse.winery.repository.rest.resources.entitytypeimplementations.relationshiptypeimplementations.RelationshipTypeImplementationsResource 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();
}
Also used : TRelationshipType(org.eclipse.winery.model.tosca.TRelationshipType) RelationshipTypeImplementationsResource(org.eclipse.winery.repository.rest.resources.entitytypeimplementations.relationshiptypeimplementations.RelationshipTypeImplementationsResource) RelationshipTypeId(org.eclipse.winery.model.ids.definitions.RelationshipTypeId) TInterface(org.eclipse.winery.model.tosca.TInterface) INodeTemplateResourceOrNodeTypeImplementationResourceOrRelationshipTypeImplementationResource(org.eclipse.winery.repository.rest.resources._support.INodeTemplateResourceOrNodeTypeImplementationResourceOrRelationshipTypeImplementationResource) RelationshipTypeImplementationResource(org.eclipse.winery.repository.rest.resources.entitytypeimplementations.relationshiptypeimplementations.RelationshipTypeImplementationResource) NodeTypeImplementationsResource(org.eclipse.winery.repository.rest.resources.entitytypeimplementations.nodetypeimplementations.NodeTypeImplementationsResource) ArrayList(java.util.ArrayList) NodeTypeImplementationResource(org.eclipse.winery.repository.rest.resources.entitytypeimplementations.nodetypeimplementations.NodeTypeImplementationResource) IRepository(org.eclipse.winery.repository.backend.IRepository) TNodeType(org.eclipse.winery.model.tosca.TNodeType)

Aggregations

ArrayList (java.util.ArrayList)1 RelationshipTypeId (org.eclipse.winery.model.ids.definitions.RelationshipTypeId)1 TInterface (org.eclipse.winery.model.tosca.TInterface)1 TNodeType (org.eclipse.winery.model.tosca.TNodeType)1 TRelationshipType (org.eclipse.winery.model.tosca.TRelationshipType)1 IRepository (org.eclipse.winery.repository.backend.IRepository)1 INodeTemplateResourceOrNodeTypeImplementationResourceOrRelationshipTypeImplementationResource (org.eclipse.winery.repository.rest.resources._support.INodeTemplateResourceOrNodeTypeImplementationResourceOrRelationshipTypeImplementationResource)1 NodeTypeImplementationResource (org.eclipse.winery.repository.rest.resources.entitytypeimplementations.nodetypeimplementations.NodeTypeImplementationResource)1 NodeTypeImplementationsResource (org.eclipse.winery.repository.rest.resources.entitytypeimplementations.nodetypeimplementations.NodeTypeImplementationsResource)1 RelationshipTypeImplementationResource (org.eclipse.winery.repository.rest.resources.entitytypeimplementations.relationshiptypeimplementations.RelationshipTypeImplementationResource)1 RelationshipTypeImplementationsResource (org.eclipse.winery.repository.rest.resources.entitytypeimplementations.relationshiptypeimplementations.RelationshipTypeImplementationsResource)1