Search in sources :

Example 11 with OrderParameter

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

the class ExecutionEngineImplTest method createOrder.

protected Order createOrder(String name, Map<String, String> params) {
    ExecutionState state = new ExecutionState();
    modelClient.save(state);
    Order order = new Order();
    order.setExecutionStateId(state.getId());
    CatalogService service = new CatalogService();
    service.setLabel(name);
    modelClient.save(service);
    order.setCatalogServiceId(service.getId());
    modelClient.save(order);
    int index = 0;
    for (Map.Entry<String, String> entry : params.entrySet()) {
        OrderParameter param = new OrderParameter();
        param.setLabel(entry.getKey());
        param.setValue(entry.getValue());
        param.setOrderId(order.getId());
        modelClient.save(param);
    }
    return order;
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) ExecutionState(com.emc.storageos.db.client.model.uimodels.ExecutionState) OrderParameter(com.emc.storageos.db.client.model.uimodels.OrderParameter) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) Map(java.util.Map)

Example 12 with OrderParameter

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

the class OrderParameterTest method create.

protected static OrderParameter create(String name, String value) {
    OrderParameter model = new OrderParameter();
    model.setLabel(name);
    model.setFriendlyLabel(name);
    model.setFriendlyValue(value);
    model.setValue(value);
    return model;
}
Also used : OrderParameter(com.emc.storageos.db.client.model.uimodels.OrderParameter)

Example 13 with OrderParameter

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

the class SortedIndexTest method testSorting.

@Test
public void testSorting() {
    Order o1 = createOrder(OrderStatus.PENDING);
    ModelClient modelClient = getModelClient();
    modelClient.save(o1);
    OrderParameter op1 = createOrderParameter("op1", "op1Value", 2);
    op1.setOrderId(o1.getId());
    modelClient.save(op1);
    OrderParameter op2 = createOrderParameter("op2", "op2Value", 1);
    op2.setOrderId(o1.getId());
    modelClient.save(op2);
    OrderParameter op3 = createOrderParameter("op3", "op3Value", 3);
    op3.setOrderId(o1.getId());
    modelClient.save(op3);
    List<OrderParameter> orderParameters = modelClient.orderParameters().findByOrderId(o1.getId());
    Assert.assertNotNull(orderParameters);
    Assert.assertEquals(3, orderParameters.size());
    Assert.assertEquals(op2.getLabel(), orderParameters.get(0).getLabel());
    Assert.assertEquals(op1.getLabel(), orderParameters.get(1).getLabel());
    Assert.assertEquals(op3.getLabel(), orderParameters.get(2).getLabel());
    SortedIndexUtils.moveDown(op1, modelClient);
    orderParameters = modelClient.orderParameters().findByOrderId(o1.getId());
    Assert.assertNotNull(orderParameters);
    Assert.assertEquals(3, orderParameters.size());
    Assert.assertEquals(op2.getLabel(), orderParameters.get(0).getLabel());
    Assert.assertEquals(op3.getLabel(), orderParameters.get(1).getLabel());
    Assert.assertEquals(op1.getLabel(), orderParameters.get(2).getLabel());
    SortedIndexUtils.moveUp(op3, modelClient);
    orderParameters = modelClient.orderParameters().findByOrderId(o1.getId());
    Assert.assertNotNull(orderParameters);
    Assert.assertEquals(3, orderParameters.size());
    Assert.assertEquals(op3.getLabel(), orderParameters.get(0).getLabel());
    Assert.assertEquals(op2.getLabel(), orderParameters.get(1).getLabel());
    Assert.assertEquals(op1.getLabel(), orderParameters.get(2).getLabel());
    OrderParameter op4 = createOrderParameter("op4", "op4Value", null);
    op4.setOrderId(o1.getId());
    modelClient.save(op4);
    orderParameters = modelClient.orderParameters().findByOrderId(o1.getId());
    Assert.assertNotNull(orderParameters);
    Assert.assertEquals(4, orderParameters.size());
    Assert.assertEquals(op3.getLabel(), orderParameters.get(0).getLabel());
    Assert.assertEquals(op2.getLabel(), orderParameters.get(1).getLabel());
    Assert.assertEquals(op1.getLabel(), orderParameters.get(2).getLabel());
    Assert.assertEquals(op4.getLabel(), orderParameters.get(3).getLabel());
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) OrderParameter(com.emc.storageos.db.client.model.uimodels.OrderParameter) ModelClient(com.emc.sa.model.dao.ModelClient) Test(org.junit.Test)

Example 14 with OrderParameter

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

the class ServiceRunner method createParam.

private static OrderParameter createParam(String name, String value) {
    OrderParameter param = new OrderParameter();
    param.setLabel(name);
    param.setValue(value);
    return save(param);
}
Also used : OrderParameter(com.emc.storageos.db.client.model.uimodels.OrderParameter)

Example 15 with OrderParameter

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

the class ServiceRunner method createOrder.

public static Order createOrder(String name, Map<String, String> params) {
    init();
    Order order = new Order();
    order.setCatalogServiceId(createService(name).getId());
    order = save(order);
    for (Map.Entry<String, String> entry : params.entrySet()) {
        OrderParameter param = createParam(entry.getKey(), entry.getValue());
        param.setOrderId(order.getId());
        getModels().save(param);
    }
    return order;
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) OrderParameter(com.emc.storageos.db.client.model.uimodels.OrderParameter) Map(java.util.Map)

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