Search in sources :

Example 1 with AbstractToscaType

use of org.alien4cloud.tosca.model.types.AbstractToscaType in project alien4cloud by alien4cloud.

the class EditorStepDefs method iShouldBeAbleToFindAComponentWithId.

@And("^I should be able to find a component with id \"([^\"]*)\"$")
public void iShouldBeAbleToFindAComponentWithId(String id) throws Throwable {
    AbstractToscaType compoennt = alienDAO.findById(AbstractToscaType.class, id);
    Assert.assertNotNull(compoennt);
}
Also used : AbstractToscaType(org.alien4cloud.tosca.model.types.AbstractToscaType) And(cucumber.api.java.en.And)

Example 2 with AbstractToscaType

use of org.alien4cloud.tosca.model.types.AbstractToscaType in project alien4cloud by alien4cloud.

the class PluginArchiveIndexer method injectWorkSpace.

private void injectWorkSpace(Collection<? extends AbstractToscaType> elements, Orchestrator orchestrator, Location location) {
    for (AbstractToscaType element : elements) {
        if (element.getTags() == null) {
            element.setTags(new ArrayList<Tag>());
        }
        element.getTags().add(new Tag("alien-workspace-id", orchestrator.getId() + ":" + location.getId()));
        element.getTags().add(new Tag("alien-workspace-name", orchestrator.getName() + " - " + location.getName()));
    }
}
Also used : AbstractToscaType(org.alien4cloud.tosca.model.types.AbstractToscaType) Tag(alien4cloud.model.common.Tag)

Example 3 with AbstractToscaType

use of org.alien4cloud.tosca.model.types.AbstractToscaType in project alien4cloud by alien4cloud.

the class ComponentController method getComponentVersions.

/**
 * Get all versions of a given component.
 *
 * @param elementId unique id of the component for which to get all other versions.
 * @return A {@link RestResponse} that contains an {@link AbstractToscaType} .
 */
@ApiOperation(value = "Get details for a component (tosca type).")
@RequestMapping(value = "/element/{elementId:.+}/versions", method = RequestMethod.GET)
@PreAuthorize("hasAnyAuthority('ADMIN', 'COMPONENTS_MANAGER', 'COMPONENTS_BROWSER')")
public RestResponse<CatalogVersionResult[]> getComponentVersions(@PathVariable String elementId, @RequestParam(required = false) QueryComponentType toscaType) {
    Class<? extends AbstractToscaType> queryClass = toscaType == null ? AbstractToscaType.class : toscaType.getIndexedToscaElementClass();
    Object array = toscaTypeSearchService.findAll(queryClass, elementId);
    if (array != null) {
        int length = Array.getLength(array);
        CatalogVersionResult[] versions = new CatalogVersionResult[length];
        for (int i = 0; i < length; i++) {
            AbstractToscaType element = ((AbstractToscaType) Array.get(array, i));
            versions[i] = new CatalogVersionResult(element.getId(), element.getArchiveVersion());
        }
        return RestResponseBuilder.<CatalogVersionResult[]>builder().data(versions).build();
    }
    return RestResponseBuilder.<CatalogVersionResult[]>builder().data(new CatalogVersionResult[0]).build();
}
Also used : CatalogVersionResult(org.alien4cloud.tosca.catalog.CatalogVersionResult) AbstractToscaType(org.alien4cloud.tosca.model.types.AbstractToscaType) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with AbstractToscaType

use of org.alien4cloud.tosca.model.types.AbstractToscaType in project alien4cloud by alien4cloud.

the class ComponentController method getComponent.

@ApiOperation(value = "Get details for a component (tosca type).")
@RequestMapping(value = "/getInArchives", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasAnyAuthority('ADMIN', 'COMPONENTS_MANAGER', 'COMPONENTS_BROWSER')")
public RestResponse<AbstractToscaType> getComponent(@RequestBody ElementFromArchiveRequest checkElementExistRequest) throws ClassNotFoundException {
    Class<? extends AbstractToscaType> elementClass = checkElementExistRequest.getComponentType().getIndexedToscaElementClass();
    AbstractToscaType element = toscaTypeSearchService.getElementInDependencies(elementClass, checkElementExistRequest.getElementName(), checkElementExistRequest.getDependencies());
    return RestResponseBuilder.<AbstractToscaType>builder().data(element).build();
}
Also used : AbstractToscaType(org.alien4cloud.tosca.model.types.AbstractToscaType) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with AbstractToscaType

use of org.alien4cloud.tosca.model.types.AbstractToscaType in project alien4cloud by alien4cloud.

the class ToscaTypeIndexerService method deleteElements.

@Override
public void deleteElements(String name, String version) {
    GetMultipleDataResult<AbstractToscaType> result = alienDAO.buildQuery(AbstractToscaType.class).setFilters(fromKeyValueCouples("archiveName", name, "archiveVersion", version)).prepareSearch().setFetchContext(FetchContext.SUMMARY).search(0, Integer.MAX_VALUE);
    AbstractToscaType[] elements = result.getData();
    // we need to delete each element
    for (AbstractToscaType element : elements) {
        deleteElement(element);
    }
}
Also used : AbstractToscaType(org.alien4cloud.tosca.model.types.AbstractToscaType)

Aggregations

AbstractToscaType (org.alien4cloud.tosca.model.types.AbstractToscaType)15 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 ApiOperation (io.swagger.annotations.ApiOperation)3 NodeType (org.alien4cloud.tosca.model.types.NodeType)3 Tag (alien4cloud.model.common.Tag)2 Given (cucumber.api.java.en.Given)2 FacetedSearchResult (alien4cloud.dao.model.FacetedSearchResult)1 GetMultipleDataResult (alien4cloud.dao.model.GetMultipleDataResult)1 NotFoundException (alien4cloud.exception.NotFoundException)1 Application (alien4cloud.model.application.Application)1 And (cucumber.api.java.en.And)1 HashMap (java.util.HashMap)1 Set (java.util.Set)1 SneakyThrows (lombok.SneakyThrows)1 CatalogVersionResult (org.alien4cloud.tosca.catalog.CatalogVersionResult)1 CSARDependency (org.alien4cloud.tosca.model.CSARDependency)1 Csar (org.alien4cloud.tosca.model.Csar)1 CapabilityDefinition (org.alien4cloud.tosca.model.definitions.CapabilityDefinition)1 Interface (org.alien4cloud.tosca.model.definitions.Interface)1