Search in sources :

Example 76 with NamedURI

use of com.emc.storageos.db.client.model.NamedURI in project coprhd-controller by CoprHD.

the class ScheduledEventService method createScheduledEvent.

/**
 * Internal main function to create scheduled event.
 * @param tenantId          owner tenant Id
 * @param param             scheduled event creation param
 * @param catalogService   target catalog service
 * @return                   ScheduledEvent
 * @throws Exception
 */
private ScheduledEvent createScheduledEvent(StorageOSUser user, URI tenantId, ScheduledEventCreateParam param, CatalogService catalogService) throws Exception {
    // INFINITE execution window
    URI executionWindow = null;
    if (catalogService.getExecutionWindowRequired()) {
        if (catalogService.getDefaultExecutionWindowId() == null || catalogService.getDefaultExecutionWindowId().equals(ExecutionWindow.NEXT)) {
            List<URI> executionWindows = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getExecutionWindowTenantIdIdConstraint(tenantId.toString()));
            Calendar currTime = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
            executionWindow = getNextExecutionWindow(executionWindows, currTime);
        } else {
            executionWindow = catalogService.getDefaultExecutionWindowId().getURI();
        }
        ExecutionWindow window = client.findById(executionWindow);
        String msg = match(param.getScheduleInfo(), window);
        if (!msg.isEmpty()) {
            throw APIException.badRequests.scheduleInfoNotMatchWithExecutionWindow(msg);
        }
    }
    URI scheduledEventId = URIUtil.createId(ScheduledEvent.class);
    param.getOrderCreateParam().setScheduledEventId(scheduledEventId);
    Calendar scheduledTime = ScheduleTimeHelper.getFirstScheduledTime(param.getScheduleInfo());
    param.getOrderCreateParam().setScheduledTime(ScheduleTimeHelper.convertCalendarToStr(scheduledTime));
    param.getOrderCreateParam().setExecutionWindow(executionWindow);
    OrderRestRep restRep = orderService.createOrder(param.getOrderCreateParam());
    ScheduledEvent newObject = new ScheduledEvent();
    newObject.setId(scheduledEventId);
    newObject.setTenant(tenantId.toString());
    newObject.setCatalogServiceId(param.getOrderCreateParam().getCatalogService());
    newObject.setEventType(param.getScheduleInfo().getReoccurrence() == 1 ? ScheduledEventType.ONCE : ScheduledEventType.REOCCURRENCE);
    if (catalogService.getApprovalRequired()) {
        log.info(String.format("ScheduledEventr %s requires approval", newObject.getId()));
        newObject.setEventStatus(ScheduledEventStatus.APPROVAL);
    } else {
        newObject.setEventStatus(ScheduledEventStatus.APPROVED);
    }
    newObject.setScheduleInfo(new String(org.apache.commons.codec.binary.Base64.encodeBase64(param.getScheduleInfo().serialize()), UTF_8));
    if (executionWindow != null) {
        newObject.setExecutionWindowId(new NamedURI(executionWindow, "ExecutionWindow"));
    }
    newObject.setLatestOrderId(restRep.getId());
    newObject.setOrderCreationParam(new String(org.apache.commons.codec.binary.Base64.encodeBase64(param.getOrderCreateParam().serialize()), UTF_8));
    newObject.setStorageOSUser(new String(org.apache.commons.codec.binary.Base64.encodeBase64(user.serialize()), UTF_8));
    client.save(newObject);
    log.info("Created a new scheduledEvent {}:{}", newObject.getId(), param.getScheduleInfo().toString());
    return newObject;
}
Also used : NamedURI(com.emc.storageos.db.client.model.NamedURI) URIUtil.asString(com.emc.storageos.db.client.URIUtil.asString) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 77 with NamedURI

use of com.emc.storageos.db.client.model.NamedURI in project coprhd-controller by CoprHD.

the class OrderMapper method createNewObject.

public static Order createNewObject(URI tenantId, OrderCreateParam param) {
    Order newObject = new Order();
    newObject.setId(URIUtil.createId(Order.class));
    newObject.setTenant(tenantId.toString());
    newObject.setCatalogServiceId(param.getCatalogService());
    newObject.setWorkflowDocument(param.getWorkflowDocument());
    if (param.getScheduledEventId() != null) {
        newObject.setScheduledEventId(param.getScheduledEventId());
        if (param.getScheduledTime() != null) {
            newObject.setScheduledTime(ScheduleTimeHelper.convertStrToCalendar(param.getScheduledTime()));
        }
        if (param.getExecutionWindow() == null) {
            newObject.setExecutionWindowId(null);
        } else {
            newObject.setExecutionWindowId(new NamedURI(param.getExecutionWindow(), "ExecutionWindow"));
        }
    }
    updateObject(newObject, param);
    return newObject;
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) NamedURI(com.emc.storageos.db.client.model.NamedURI)

Example 78 with NamedURI

use of com.emc.storageos.db.client.model.NamedURI in project coprhd-controller by CoprHD.

the class WorkflowHelper method addResource.

private static void addResource(Builder builder, NamedURI id, CustomServicesResourceDAOs resourceDAOs) {
    final CustomServicesResourceDAO<?> dao = resourceDAOs.getByModel(URIUtil.getTypeName(id.getURI()));
    if (null == dao) {
        throw new RuntimeException("Resource type for " + id + " not found");
    }
    final CustomServicesPrimitiveResourceType resource = dao.getResource(id.getURI());
    if (null == resource) {
        throw new RuntimeException("Resource " + id + " not found");
    }
    builder.addResource(new ResourcePackage(CustomServicesPrimitiveMapper.map(resource), resource.resource()));
    for (final NamedElement related : dao.listRelatedResources(id.getURI())) {
        addResource(builder, new NamedURI(related.getId(), related.getName()), resourceDAOs);
    }
}
Also used : NamedURI(com.emc.storageos.db.client.model.NamedURI) ResourcePackage(com.emc.sa.workflow.CustomServicesWorkflowPackage.ResourcePackage) CustomServicesPrimitiveResourceType(com.emc.storageos.primitives.CustomServicesPrimitiveResourceType) NamedElement(com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement)

Example 79 with NamedURI

use of com.emc.storageos.db.client.model.NamedURI in project coprhd-controller by CoprHD.

the class CatalogBuilder method createCategory.

public CatalogCategory createCategory(String tenant, CategoryDef def, NamedURI parentId) {
    String label = getMessage(getLabel(def));
    String title = getMessage(def.title);
    String description = getMessage(def.description);
    CatalogCategory category = new CatalogCategory();
    category.setTenant(tenant);
    category.setLabel(StringUtils.deleteWhitespace(label));
    category.setTitle(title);
    category.setDescription(description);
    category.setImage(def.image);
    category.setCatalogCategoryId(parentId);
    category.setSortedIndex(sortedIndexCounter++);
    category.setVersion(def.version);
    models.save(category);
    NamedURI myId = new NamedURI(category.getId(), category.getLabel());
    if (def.categories != null) {
        for (CategoryDef categoryDef : def.categories) {
            createCategory(tenant, categoryDef, myId);
        }
    }
    if (def.services != null) {
        for (ServiceDef serviceDef : def.services) {
            createService(serviceDef, myId);
        }
    }
    return category;
}
Also used : NamedURI(com.emc.storageos.db.client.model.NamedURI) CatalogCategory(com.emc.storageos.db.client.model.uimodels.CatalogCategory)

Example 80 with NamedURI

use of com.emc.storageos.db.client.model.NamedURI in project coprhd-controller by CoprHD.

the class CatalogServiceManagerImpl method createCatalogService.

public CatalogService createCatalogService(ServiceDef serviceDef, CatalogCategory parentCategory) {
    CatalogBuilder builder = new CatalogBuilder(client, serviceDescriptors);
    NamedURI namedUri = new NamedURI(parentCategory.getId(), parentCategory.getLabel());
    CatalogService newService = builder.createService(serviceDef, namedUri);
    newService.setSortedIndex(null);
    client.save(newService);
    return newService;
}
Also used : NamedURI(com.emc.storageos.db.client.model.NamedURI) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService)

Aggregations

NamedURI (com.emc.storageos.db.client.model.NamedURI)196 URI (java.net.URI)98 Volume (com.emc.storageos.db.client.model.Volume)74 StringSet (com.emc.storageos.db.client.model.StringSet)65 Project (com.emc.storageos.db.client.model.Project)54 ArrayList (java.util.ArrayList)46 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)43 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)42 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)36 Test (org.junit.Test)32 StoragePool (com.emc.storageos.db.client.model.StoragePool)31 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)31 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)27 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)26 StringMap (com.emc.storageos.db.client.model.StringMap)26 List (java.util.List)23 OpStatusMap (com.emc.storageos.db.client.model.OpStatusMap)20 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)20 VirtualPoolCapabilityValuesWrapper (com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper)18 FileShare (com.emc.storageos.db.client.model.FileShare)17