use of com.emc.storageos.db.client.model.uimodels.Order in project coprhd-controller by CoprHD.
the class OrderScheduleTimeCallback method process.
@Override
public void process() throws MigrationCallbackException {
log.info("Handle Order schedule time ...");
DbClient dbClient = getDbClient();
List<URI> orders = dbClient.queryByType(Order.class, true);
for (URI uri : orders) {
Order order = dbClient.queryObject(Order.class, uri);
if (order == null)
continue;
if (order.getScheduledEventId() == null) {
if (order.getExecutionWindowId() == null || order.getExecutionWindowId().getURI().equals(ExecutionWindow.NEXT)) {
Calendar scheduleTime = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
scheduleTime.setTime(order.getLastUpdated());
order.setExecutionWindowId(new NamedURI(ExecutionWindow.NEXT, "NEXT"));
order.setScheduledTime(scheduleTime);
} else {
// For original orders, set schedule time to
// either 1) the next execution window starting time
// or 2) the current time if it is in current execution window
ExecutionWindow executionWindow = dbClient.queryObject(ExecutionWindow.class, order.getExecutionWindowId().getURI());
if (executionWindow == null)
continue;
ExecutionWindowHelper helper = new ExecutionWindowHelper(executionWindow);
order.setScheduledTime(helper.getScheduledTime());
}
dbClient.updateObject(order);
}
}
return;
}
use of com.emc.storageos.db.client.model.uimodels.Order in project coprhd-controller by CoprHD.
the class DbConsistencyCheckerHelperTest method testTimeSeriesAlternateId.
@Test
public void testTimeSeriesAlternateId() throws Exception {
DbConsistencyCheckerHelperMock mockHelper = new DbConsistencyCheckerHelperMock((DbClientImpl) getDbClient());
Order order = new Order();
order.setId(URIUtil.createId(Order.class));
order.setLabel("order2");
order.setTenant("tenant");
order.setIndexed(true);
getDbClient().createObject(order);
Keyspace keyspace = ((DbClientImpl) getDbClient()).getLocalContext().getKeyspace();
ColumnFamily<String, TimeSeriesIndexColumnName> indexCF = new ColumnFamily<String, TimeSeriesIndexColumnName>("AllOrdersByTimeStamp", StringSerializer.get(), TimeSeriesColumnNameSerializer.get());
ColumnFamily<String, CompositeColumnName> cf = new ColumnFamily<String, CompositeColumnName>("Order", StringSerializer.get(), CompositeColumnNameSerializer.get());
IndexAndCf indexAndCf = new IndexAndCf(TimeSeriesDbIndex.class, indexCF, keyspace);
CheckResult checkResult = new CheckResult();
mockHelper.checkIndexingCF(indexAndCf, false, checkResult);
assertEquals(0, checkResult.getTotal());
keyspace.prepareQuery(cf).withCql(String.format("delete from \"Order\" where key='%s'", order.getId())).execute();
checkResult = new CheckResult();
mockHelper.checkIndexingCF(indexAndCf, false, checkResult);
assertEquals(1, checkResult.getTotal());
keyspace.prepareQuery(indexCF).withCql(mockHelper.getCleanIndexCQL()).execute();
checkResult = new CheckResult();
mockHelper.checkIndexingCF(indexAndCf, false, checkResult);
assertEquals(0, checkResult.getTotal());
}
use of com.emc.storageos.db.client.model.uimodels.Order in project coprhd-controller by CoprHD.
the class OrderService method createOrder.
@POST
@Path("")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public OrderRestRep createOrder(OrderCreateParam createParam) {
StorageOSUser user = getUserFromContext();
URI tenantId = createParam.getTenantId();
if (tenantId != null) {
verifyAuthorizedInTenantOrg(tenantId, user);
} else {
tenantId = uri(user.getTenantId());
}
Order order = createNewOrder(user, tenantId, createParam);
orderManager.processOrder(order);
order = orderManager.getOrderById(order.getId());
List<OrderParameter> orderParameters = orderManager.getOrderParameters(order.getId());
auditOpSuccess(OperationTypeEnum.CREATE_ORDER, order.auditParameters());
return map(order, orderParameters);
}
use of com.emc.storageos.db.client.model.uimodels.Order in project coprhd-controller by CoprHD.
the class OrderService method getOrders.
/**
* Gets the list of orders
* @param tenantId the URN of a tenant
* @brief List Orders
* @return a list of orders
* @throws DatabaseException when a DB error occurs
*/
@GET
@Path("/all")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public OrderList getOrders(@DefaultValue("") @QueryParam(SearchConstants.TENANT_ID_PARAM) String tenantId) throws DatabaseException {
StorageOSUser user = getUserFromContext();
if (StringUtils.isBlank(tenantId)) {
tenantId = user.getTenantId();
}
verifyAuthorizedInTenantOrg(uri(tenantId), getUserFromContext());
List<Order> orders = orderManager.getOrders(uri(tenantId));
return toOrderList(orders);
}
use of com.emc.storageos.db.client.model.uimodels.Order in project coprhd-controller by CoprHD.
the class OrderService method getOrderById.
private Order getOrderById(URI id, boolean checkInactive) {
Order order = orderManager.getOrderById(id);
ArgValidator.checkEntity(order, id, isIdEmbeddedInURL(id), checkInactive);
return order;
}
Aggregations