Search in sources :

Example 6 with OrderParameter

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

the class OrderParameterTest method testPersistObject.

@Test
public void testPersistObject() throws Exception {
    _logger.info("Starting persist OrderParameter test");
    OrderParameter model = new OrderParameter();
    model.setLabel("foo");
    model.setFriendlyLabel("my friendly name");
    model.setFriendlyValue("my friendly value");
    model.setUserInput(false);
    model.setValue("my value");
    save(model);
    model = findById(model.getId());
    Assert.assertNotNull(model);
    Assert.assertEquals("foo", model.getLabel());
    Assert.assertEquals("my friendly name", model.getFriendlyLabel());
    Assert.assertEquals("my friendly value", model.getFriendlyValue());
    Assert.assertEquals(false, model.getUserInput());
    Assert.assertEquals("my value", model.getValue());
}
Also used : OrderParameter(com.emc.storageos.db.client.model.uimodels.OrderParameter) BaseModelTest(com.emc.sa.model.BaseModelTest) Test(org.junit.Test)

Example 7 with OrderParameter

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

the class SortedIndexTest method createOrderParameter.

private static OrderParameter createOrderParameter(String label, String value, Integer sortedIndex) {
    OrderParameter model = new OrderParameter();
    model.setId(URIUtil.createId(OrderParameter.class));
    model.setLabel(label);
    model.setFriendlyLabel("my friendly name");
    model.setFriendlyValue("my friendly value");
    model.setUserInput(false);
    model.setValue(value);
    model.setSortedIndex(sortedIndex);
    return model;
}
Also used : OrderParameter(com.emc.storageos.db.client.model.uimodels.OrderParameter)

Example 8 with OrderParameter

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

the class OrderService method getOrder.

@GET
@Path("/{id}")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public OrderRestRep getOrder(@PathParam("id") String id) {
    Order order = queryResource(uri(id));
    StorageOSUser user = getUserFromContext();
    verifyAuthorizedInTenantOrg(uri(order.getTenant()), user);
    List<OrderParameter> orderParameters = orderManager.getOrderParameters(order.getId());
    return map(order, orderParameters);
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) OrderParameter(com.emc.storageos.db.client.model.uimodels.OrderParameter) StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) GET(javax.ws.rs.GET)

Example 9 with OrderParameter

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

the class OrderService method dumpOrder.

private void dumpOrder(PrintStream out, Order order) {
    out.print(order.toString());
    out.println("Parameters");
    out.println("----------");
    List<OrderParameter> parameters = orderManager.getOrderParameters(order.getId());
    for (OrderParameter parameter : parameters) {
        out.print(parameter.toString());
    }
    out.println("Execution State");
    out.println("---------------");
    ExecutionState state = orderManager.getOrderExecutionState(order.getExecutionStateId());
    if (state != null) {
        out.print(state.toString());
    }
    out.println("Logs");
    out.println("----");
    out.println(" Execution Logs");
    if (state != null) {
        List<ExecutionLog> elogs = orderManager.getOrderExecutionLogs(order);
        for (ExecutionLog elog : elogs) {
            out.print(elog.toString());
        }
    }
    out.println(" Execution Task Logs");
    if (state != null) {
        List<ExecutionTaskLog> tlogs = orderManager.getOrderExecutionTaskLogs(order);
        for (ExecutionTaskLog tlog : tlogs) {
            out.print(tlog.toString());
        }
    }
}
Also used : ExecutionState(com.emc.storageos.db.client.model.uimodels.ExecutionState) ExecutionLog(com.emc.storageos.db.client.model.uimodels.ExecutionLog) OrderParameter(com.emc.storageos.db.client.model.uimodels.OrderParameter) ExecutionTaskLog(com.emc.storageos.db.client.model.uimodels.ExecutionTaskLog)

Example 10 with OrderParameter

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

the class ExecutionUtils method createContext.

public static void createContext(ModelClient modelClient, Order order) {
    // Ensure there is no existing context
    destroyContext();
    // Initialize the execution state for this order
    ExecutionState state = modelClient.executionStates().findById(order.getExecutionStateId());
    state.setStartDate(new Date());
    ExecutionContext context = currentContext();
    context.setOrder(order);
    context.setModelClient(modelClient);
    context.setExecutionState(state);
    URI scheduledEventId = order.getScheduledEventId();
    if (scheduledEventId != null) {
        ScheduledEvent event = modelClient.findById(ScheduledEvent.class, scheduledEventId);
        context.setScheduledEvent(event);
    }
    CatalogService catalogService = modelClient.catalogServices().findById(order.getCatalogServiceId());
    if (null != catalogService) {
        context.setServiceName(catalogService.getLabel());
    }
    List<OrderParameter> orderParameters = modelClient.orderParameters().findByOrderId(order.getId());
    Map<String, Object> params = Maps.newLinkedHashMap();
    for (OrderParameter param : orderParameters) {
        params.put(param.getLabel(), param.getValue());
    }
    context.setParameters(params);
}
Also used : ExecutionState(com.emc.storageos.db.client.model.uimodels.ExecutionState) ScheduledEvent(com.emc.storageos.db.client.model.uimodels.ScheduledEvent) OrderParameter(com.emc.storageos.db.client.model.uimodels.OrderParameter) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) URI(java.net.URI) Date(java.util.Date)

Aggregations

OrderParameter (com.emc.storageos.db.client.model.uimodels.OrderParameter)15 Order (com.emc.storageos.db.client.model.uimodels.Order)7 CatalogService (com.emc.storageos.db.client.model.uimodels.CatalogService)3 ExecutionState (com.emc.storageos.db.client.model.uimodels.ExecutionState)3 StorageOSUser (com.emc.storageos.security.authentication.StorageOSUser)2 OrderRestRep (com.emc.vipr.model.catalog.OrderRestRep)2 Parameter (com.emc.vipr.model.catalog.Parameter)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 Consumes (javax.ws.rs.Consumes)2 Path (javax.ws.rs.Path)2 Test (org.junit.Test)2 WorkflowServiceDescriptor (com.emc.sa.catalog.WorkflowServiceDescriptor)1 ServiceDescriptor (com.emc.sa.descriptor.ServiceDescriptor)1 BaseModelTest (com.emc.sa.model.BaseModelTest)1 ModelClient (com.emc.sa.model.dao.ModelClient)1 URIUtil.asString (com.emc.storageos.db.client.URIUtil.asString)1 ExecutionLog (com.emc.storageos.db.client.model.uimodels.ExecutionLog)1 ExecutionTaskLog (com.emc.storageos.db.client.model.uimodels.ExecutionTaskLog)1