Search in sources :

Example 1 with QNameApiData

use of org.eclipse.winery.repository.rest.resources.apiData.QNameApiData in project winery by eclipse.

the class ImplementationsOfOneNodeTypeResource method getJSON.

@Override
public Response getJSON() {
    Collection<NodeTypeImplementationId> allImplementations = RepositoryFactory.getRepository().getAllElementsReferencingGivenType(NodeTypeImplementationId.class, this.getTypeId().getQName());
    List<QNameApiData> res = new ArrayList<>(allImplementations.size());
    QNameConverter adapter = new QNameConverter();
    for (NodeTypeImplementationId id : allImplementations) {
        res.add(adapter.marshal(id.getQName()));
    }
    return Response.ok().entity(res).build();
}
Also used : NodeTypeImplementationId(org.eclipse.winery.common.ids.definitions.NodeTypeImplementationId) QNameApiData(org.eclipse.winery.repository.rest.resources.apiData.QNameApiData) ArrayList(java.util.ArrayList) QNameConverter(org.eclipse.winery.repository.rest.resources.apiData.converter.QNameConverter)

Example 2 with QNameApiData

use of org.eclipse.winery.repository.rest.resources.apiData.QNameApiData in project winery by eclipse.

the class ImplementationsOfOneRelationshipTypeResource method getJSON.

@Override
public Response getJSON() {
    Collection<RelationshipTypeImplementationId> allImplementations = RepositoryFactory.getRepository().getAllElementsReferencingGivenType(RelationshipTypeImplementationId.class, this.getTypeId().getQName());
    List<QNameApiData> res = new ArrayList<>(allImplementations.size());
    QNameConverter adapter = new QNameConverter();
    for (RelationshipTypeImplementationId id : allImplementations) {
        res.add(adapter.marshal(id.getQName()));
    }
    return Response.ok().entity(res).build();
}
Also used : QNameApiData(org.eclipse.winery.repository.rest.resources.apiData.QNameApiData) ArrayList(java.util.ArrayList) RelationshipTypeImplementationId(org.eclipse.winery.common.ids.definitions.RelationshipTypeImplementationId) QNameConverter(org.eclipse.winery.repository.rest.resources.apiData.converter.QNameConverter)

Example 3 with QNameApiData

use of org.eclipse.winery.repository.rest.resources.apiData.QNameApiData in project winery by eclipse.

the class ServiceTemplateResource method createNewStatefulVersion.

@POST()
@Path("createnewstatefulversion")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response createNewStatefulVersion() {
    LOGGER.debug("Creating new stateful version of Service Template {}...", this.getId());
    ServiceTemplateId id = (ServiceTemplateId) this.getId();
    WineryVersion version = id.getVersion();
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd-HHmmss");
    WineryVersion newVersion = new WineryVersion("stateful-" + version.toString() + "-" + dateFormat.format(new Date()), 1, 0);
    ServiceTemplateId newId = new ServiceTemplateId(id.getNamespace().getDecoded(), id.getNameWithoutVersion() + WineryVersion.WINERY_NAME_FROM_VERSION_SEPARATOR + newVersion.toString(), false);
    ResourceResult response = RestUtils.duplicate(id, newId);
    if (response.getStatus() == Status.CREATED) {
        response.setUri(null);
        response.setMessage(new QNameApiData(newId));
    }
    LOGGER.debug("Created Service Template {}", newId.getQName());
    return response.getResponse();
}
Also used : ResourceResult(org.eclipse.winery.repository.rest.resources._support.ResourceResult) QNameApiData(org.eclipse.winery.repository.rest.resources.apiData.QNameApiData) ServiceTemplateId(org.eclipse.winery.model.ids.definitions.ServiceTemplateId) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) WineryVersion(org.eclipse.winery.common.version.WineryVersion) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Example 4 with QNameApiData

use of org.eclipse.winery.repository.rest.resources.apiData.QNameApiData in project winery by eclipse.

the class ServiceTemplateResource method createNewPlaceholderVersion.

@POST()
@Path("createplaceholderversion")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response createNewPlaceholderVersion() throws IOException {
    LOGGER.debug("Creating new placeholder version of Service Template {}...", this.getId());
    ServiceTemplateId id = (ServiceTemplateId) this.getId();
    WineryVersion version = VersionUtils.getVersion(id.getXmlId().getDecoded());
    WineryVersion newVersion = new WineryVersion("gdm-" + version.toString(), 1, 1);
    IRepository repository = RepositoryFactory.getRepository();
    ServiceTemplateId newId = new ServiceTemplateId(id.getNamespace().getDecoded(), VersionUtils.getNameWithoutVersion(id.getXmlId().getDecoded()) + WineryVersion.WINERY_NAME_FROM_VERSION_SEPARATOR + newVersion.toString(), false);
    if (repository.exists(newId)) {
        repository.forceDelete(newId);
    }
    ResourceResult response = RestUtils.duplicate(id, newId);
    if (response.getStatus() == Status.CREATED) {
        response.setUri(null);
        response.setMessage(new QNameApiData(newId));
    }
    LOGGER.debug("Created Service Template {}", newId.getQName());
    return response.getResponse();
}
Also used : ResourceResult(org.eclipse.winery.repository.rest.resources._support.ResourceResult) QNameApiData(org.eclipse.winery.repository.rest.resources.apiData.QNameApiData) ServiceTemplateId(org.eclipse.winery.model.ids.definitions.ServiceTemplateId) IRepository(org.eclipse.winery.repository.backend.IRepository) WineryVersion(org.eclipse.winery.common.version.WineryVersion) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Example 5 with QNameApiData

use of org.eclipse.winery.repository.rest.resources.apiData.QNameApiData in project winery by eclipse.

the class ServiceTemplateResource method createLiveModelingVersion.

@POST()
@Path("createlivemodelingversion")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response createLiveModelingVersion() {
    LOGGER.debug("Creating live modeling version of Service Template {}...", this.getId().getQName());
    ServiceTemplateId id = (ServiceTemplateId) this.getId();
    WineryVersion version = VersionUtils.getVersion(id.getQName().toString());
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd-HHmmss");
    WineryVersion newVersion = new WineryVersion(version.toString() + "-live-" + dateFormat.format(new Date()), 1, 0);
    String newComponentVersionId = VersionSupport.getNewComponentVersionId(id, "live-" + dateFormat.format(new Date()));
    ServiceTemplateId newId = new ServiceTemplateId(id.getNamespace().getDecoded(), newComponentVersionId, false);
    ResourceResult response = RestUtils.duplicate(id, newId);
    if (response.getStatus() == Status.CREATED) {
        response.setUri(null);
        response.setMessage(new QNameApiData(newId));
    }
    LOGGER.debug("Created Service Template {}", newId.getQName());
    return response.getResponse();
}
Also used : ResourceResult(org.eclipse.winery.repository.rest.resources._support.ResourceResult) QNameApiData(org.eclipse.winery.repository.rest.resources.apiData.QNameApiData) ServiceTemplateId(org.eclipse.winery.model.ids.definitions.ServiceTemplateId) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) WineryVersion(org.eclipse.winery.common.version.WineryVersion) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Aggregations

QNameApiData (org.eclipse.winery.repository.rest.resources.apiData.QNameApiData)11 Path (javax.ws.rs.Path)6 Produces (javax.ws.rs.Produces)6 WineryVersion (org.eclipse.winery.common.version.WineryVersion)6 ArrayList (java.util.ArrayList)5 POST (javax.ws.rs.POST)5 ServiceTemplateId (org.eclipse.winery.model.ids.definitions.ServiceTemplateId)5 ResourceResult (org.eclipse.winery.repository.rest.resources._support.ResourceResult)5 IRepository (org.eclipse.winery.repository.backend.IRepository)3 QNameConverter (org.eclipse.winery.repository.rest.resources.apiData.converter.QNameConverter)3 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 TServiceTemplate (org.eclipse.winery.model.tosca.TServiceTemplate)2 TTag (org.eclipse.winery.model.tosca.TTag)2 TTopologyTemplate (org.eclipse.winery.model.tosca.TTopologyTemplate)2 OTParticipant (org.eclipse.winery.model.tosca.extensions.OTParticipant)2 Splitting (org.eclipse.winery.repository.splitting.Splitting)2 ApiResponse (io.swagger.annotations.ApiResponse)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1