Search in sources :

Example 1 with CatalogServiceRestRep

use of com.emc.vipr.model.catalog.CatalogServiceRestRep in project coprhd-controller by CoprHD.

the class CatalogServiceService method queryBulkResourceReps.

private CatalogServiceBulkRep queryBulkResourceReps(List<URI> ids, CatalogServiceFilter filter) {
    List<CatalogServiceRestRep> catalogServiceRestReps = new ArrayList<CatalogServiceRestRep>();
    List<CatalogServiceAndFields> catalogServicesWithFields = catalogServiceManager.getCatalogServicesWithFields(ids);
    Map<String, ServiceDescriptor> descriptors = getServiceDescriptors();
    for (CatalogServiceAndFields catalogServiceAndField : catalogServicesWithFields) {
        if ((filter == null) || filter.isAccessible(catalogServiceAndField.getCatalogService())) {
            CatalogService service = catalogServiceAndField.getCatalogService();
            ServiceDescriptor descriptor = descriptors.get(service.getBaseService());
            List<CatalogServiceField> serviceFields = catalogServiceAndField.getCatalogServiceFields();
            catalogServiceRestReps.add(map(service, descriptor, serviceFields));
        }
    }
    catalogServiceRestReps = SortedIndexUtils.createSortedList(catalogServiceRestReps.iterator());
    return new CatalogServiceBulkRep(catalogServiceRestReps);
}
Also used : CatalogServiceField(com.emc.storageos.db.client.model.uimodels.CatalogServiceField) WorkflowServiceDescriptor(com.emc.sa.catalog.WorkflowServiceDescriptor) ServiceDescriptor(com.emc.sa.descriptor.ServiceDescriptor) CatalogServiceBulkRep(com.emc.vipr.model.catalog.CatalogServiceBulkRep) ArrayList(java.util.ArrayList) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) CatalogServiceRestRep(com.emc.vipr.model.catalog.CatalogServiceRestRep) CatalogServiceAndFields(com.emc.storageos.db.client.model.uimodels.CatalogServiceAndFields)

Example 2 with CatalogServiceRestRep

use of com.emc.vipr.model.catalog.CatalogServiceRestRep in project coprhd-controller by CoprHD.

the class CatalogServiceMapper method map.

public static CatalogServiceRestRep map(CatalogService from, ServiceDescriptor descriptor, List<CatalogServiceField> catalogServiceFields) {
    if (from == null) {
        return null;
    }
    CatalogServiceRestRep to = new CatalogServiceRestRep();
    mapDataObjectFields(from, to);
    if (from.getCatalogCategoryId() != null) {
        to.setCatalogCategory(toRelatedResource(ResourceTypeEnum.CATALOG_CATEGORY, from.getCatalogCategoryId().getURI()));
    }
    if (from.getDefaultExecutionWindowId() != null) {
        to.setDefaultExecutionWindow(toRelatedResource(ResourceTypeEnum.EXECUTION_WINDOW, from.getDefaultExecutionWindowId().getURI()));
    }
    if (from.getApprovalRequired() != null) {
        to.setApprovalRequired(from.getApprovalRequired());
    }
    if (from.getExecutionWindowRequired() != null) {
        to.setExecutionWindowRequired(from.getExecutionWindowRequired());
    }
    to.setBaseService(from.getBaseService());
    to.setDescription(from.getDescription());
    to.setImage(from.getImage());
    to.setMaxSize(from.getMaxSize());
    to.setTitle(from.getTitle());
    to.setSortedIndex(from.getSortedIndex());
    if (descriptor != null) {
        to.setServiceDescriptor(ServiceDescriptorMapper.map(descriptor));
    }
    if (catalogServiceFields != null) {
        for (CatalogServiceField catalogServiceField : catalogServiceFields) {
            CatalogServiceFieldRestRep catalogServiceFieldRestRep = new CatalogServiceFieldRestRep();
            mapDataObjectFields(catalogServiceField, catalogServiceFieldRestRep);
            catalogServiceFieldRestRep.setOverride(catalogServiceField.getOverride());
            catalogServiceFieldRestRep.setValue(catalogServiceField.getValue());
            catalogServiceFieldRestRep.setSortedIndex(catalogServiceField.getSortedIndex());
            to.getCatalogServiceFields().add(catalogServiceFieldRestRep);
        }
    }
    if (from.getRecurringAllowed() != null) {
        to.setRecurringAllowed(from.getRecurringAllowed());
    }
    return to;
}
Also used : CatalogServiceFieldRestRep(com.emc.vipr.model.catalog.CatalogServiceFieldRestRep) CatalogServiceField(com.emc.storageos.db.client.model.uimodels.CatalogServiceField) CatalogServiceRestRep(com.emc.vipr.model.catalog.CatalogServiceRestRep)

Example 3 with CatalogServiceRestRep

use of com.emc.vipr.model.catalog.CatalogServiceRestRep in project coprhd-controller by CoprHD.

the class EditCatalog method serviceFields.

public static void serviceFields(String baseService, String serviceId) {
    ServiceDescriptorRestRep serviceDescriptor = ServiceDescriptorUtils.getDescriptor(baseService);
    ServiceForm service = null;
    if (StringUtils.isNotBlank(serviceId)) {
        CatalogServiceRestRep dbService = CatalogServiceUtils.getCatalogService(uri(serviceId));
        if (dbService != null) {
            service = new ServiceForm(dbService);
        } else {
            service = new ServiceForm();
            service.baseService = baseService;
        }
    }
    addFieldOptions(baseService);
    render(serviceDescriptor, service);
}
Also used : ServiceDescriptorRestRep(com.emc.vipr.model.catalog.ServiceDescriptorRestRep) CatalogServiceRestRep(com.emc.vipr.model.catalog.CatalogServiceRestRep)

Example 4 with CatalogServiceRestRep

use of com.emc.vipr.model.catalog.CatalogServiceRestRep in project coprhd-controller by CoprHD.

the class EditCatalog method editService.

public static void editService(String serviceId, String fromId) {
    CatalogServiceRestRep catalogService = CatalogServiceUtils.getCatalogService(uri(serviceId));
    ServiceForm service = new ServiceForm(catalogService);
    service.fromId = StringUtils.defaultIfBlank(fromId, service.owningCategoryId);
    edit(service);
}
Also used : CatalogServiceRestRep(com.emc.vipr.model.catalog.CatalogServiceRestRep)

Example 5 with CatalogServiceRestRep

use of com.emc.vipr.model.catalog.CatalogServiceRestRep in project coprhd-controller by CoprHD.

the class OrderExecution method createScheduledOrder.

protected static ScheduledEventCreateParam createScheduledOrder(OrderCreateParam orderParam) {
    if (!isSchedulerEnabled()) {
        return null;
    }
    ScheduleInfo scheduleInfo = new ScheduleInfo();
    String cycleFrequency = params.get("scheduler.cycleFrequency");
    if (cycleFrequency != null) {
        scheduleInfo.setCycleFrequency(Integer.parseInt(cycleFrequency));
    } else {
        scheduleInfo.setCycleFrequency(1);
    }
    String cycleType = params.get("scheduler.cycleType");
    if (cycleType != null) {
        ScheduleCycleType cycleTypeEnum = ScheduleCycleType.valueOf(cycleType);
        scheduleInfo.setCycleType(cycleTypeEnum);
        List<String> sectionsInCycleList = Lists.newArrayList();
        if (cycleTypeEnum == ScheduleCycleType.WEEKLY) {
            String sectionsInCycle = params.get("scheduler.dayOfWeek");
            sectionsInCycleList.add(sectionsInCycle);
        } else if (cycleTypeEnum == ScheduleCycleType.MONTHLY) {
            String sectionsInCycle = params.get("scheduler.dayOfMonth");
            sectionsInCycleList.add(sectionsInCycle);
        }
        scheduleInfo.setSectionsInCycle(sectionsInCycleList);
    } else {
        scheduleInfo.setCycleType(ScheduleCycleType.DAILY);
    }
    String currentTimezoneOffsetInMins = params.get("scheduler.currentTimezoneOffsetInMins");
    Integer timezoneOffset = Integer.parseInt(currentTimezoneOffsetInMins);
    String startDate = params.get("scheduler.startDate");
    String startTime = params.get("scheduler.startTime");
    String isoDateTimeStr = String.format("%sT%s", startDate, startTime);
    DateTime startDateTime = DateTime.parse(isoDateTimeStr, ISODateTimeFormat.localDateOptionalTimeParser().withZone(TimeUtils.getLocalTimeZone(timezoneOffset)));
    startDateTime = startDateTime.withZone(DateTimeZone.UTC);
    scheduleInfo.setHourOfDay(startDateTime.getHourOfDay());
    scheduleInfo.setMinuteOfHour(startDateTime.getMinuteOfHour());
    scheduleInfo.setStartDate(String.format("%d-%02d-%02d", startDateTime.getYear(), startDateTime.getMonthOfYear(), startDateTime.getDayOfMonth()));
    String recurrence = params.get("scheduler.recurrence");
    int recurrenceNum = 1;
    if (recurrence != null) {
        recurrenceNum = Integer.parseInt(recurrence);
        if (recurrenceNum == -1) {
            String range = params.get("scheduler.rangeOfRecurrence");
            recurrenceNum = Integer.parseInt(range);
        }
    }
    scheduleInfo.setReoccurrence(recurrenceNum);
    /*
         * if reoccurence number large than 1, we must make sure the name contains patten {datetime},
         * with the pattern in the name, vipr know how to generate dynamic name for each snaphot/fullcopy.
         */
    if (recurrenceNum != 1) {
        List<Parameter> parameters = orderParam.getParameters();
        CatalogServiceRestRep service = CatalogServiceUtils.getCatalogService(orderParam.getCatalogService());
        Logger.info("creating order with parameter for: " + service.getBaseService());
        String nameToValidate = SCHEDULED_SERVICE.get(service.getBaseService());
        for (Parameter parameter : parameters) {
            if (parameter.getLabel().equals(nameToValidate) && !parameter.getValue().contains("{datetime}")) {
                Validation.addError(nameToValidate, "need to add patten '{datetime}' in the name for reoccuring scheduled operation");
            }
            Logger.info(parameter.getLabel() + " = " + parameter.getValue() + ", " + parameter.getFriendlyLabel() + " = " + parameter.getFriendlyValue());
        }
    }
    String maxNumOfCopies = params.get("scheduler.maxNumOfCopies");
    if (maxNumOfCopies != null) {
        orderParam.setAdditionalScheduleInfo(maxNumOfCopies);
    }
    scheduleInfo.setDurationLength(3600);
    ScheduledEventCreateParam eventParam = new ScheduledEventCreateParam();
    eventParam.setOrderCreateParam(orderParam);
    eventParam.setScheduleInfo(scheduleInfo);
    return eventParam;
}
Also used : Parameter(com.emc.vipr.model.catalog.Parameter) CatalogServiceRestRep(com.emc.vipr.model.catalog.CatalogServiceRestRep) ScheduledEventCreateParam(com.emc.vipr.model.catalog.ScheduledEventCreateParam) ScheduleInfo(com.emc.vipr.model.catalog.ScheduleInfo) DateTime(org.joda.time.DateTime) ScheduleCycleType(com.emc.vipr.model.catalog.ScheduleCycleType)

Aggregations

CatalogServiceRestRep (com.emc.vipr.model.catalog.CatalogServiceRestRep)29 ServiceDescriptorRestRep (com.emc.vipr.model.catalog.ServiceDescriptorRestRep)7 CatalogCategoryRestRep (com.emc.vipr.model.catalog.CatalogCategoryRestRep)6 ViPRCatalogClient2 (com.emc.vipr.client.ViPRCatalogClient2)4 ApprovalRestRep (com.emc.vipr.model.catalog.ApprovalRestRep)3 CatalogServiceFieldRestRep (com.emc.vipr.model.catalog.CatalogServiceFieldRestRep)3 OrderRestRep (com.emc.vipr.model.catalog.OrderRestRep)3 ServiceFieldRestRep (com.emc.vipr.model.catalog.ServiceFieldRestRep)3 Util (play.mvc.Util)3 CatalogServiceField (com.emc.storageos.db.client.model.uimodels.CatalogServiceField)2 DataObjectRestRep (com.emc.storageos.model.DataObjectRestRep)2 TaskUtil (com.emc.vipr.client.core.impl.TaskUtil)2 Parameter (com.emc.vipr.model.catalog.Parameter)2 URI (java.net.URI)2 HashMap (java.util.HashMap)2 DateTime (org.joda.time.DateTime)2 BourneUtil (util.BourneUtil)2 WorkflowServiceDescriptor (com.emc.sa.catalog.WorkflowServiceDescriptor)1 ServiceDescriptor (com.emc.sa.descriptor.ServiceDescriptor)1 CatalogService (com.emc.storageos.db.client.model.uimodels.CatalogService)1