@Override public void doOperation(JsonObject params, Consumer<IOperationResult> resultHandler, Consumer<Throwable> exHandler) { final SingleResult sr = new SingleResult(); final Serializable sessionId = UUID.randomUUID().toString(); sr.addMetaData("session_id", sessionId); final OperationData operationData = new OperationData(); sr.setData(operationData); JsonObject account = new JsonObject(); account.addProperty("login", "lorenzo@nexitia.com"); account.addProperty("nickName", "lorenzo"); final JsonObject user = new JsonObject(); user.addProperty("nickName", "lorenzo"); account.addProperty("mail", "lorenzo@nexitia.com"); final JsonObject container = new JsonObject(); container.addProperty("fullId", "1:people"); container.addProperty("path", "/"); operationData.getLinks().put("container", JsonUtils.toString(container)); operationData.getLinks().put("account", JsonUtils.toString(account)); operationData.getLinks().put("user", JsonUtils.toString(user)); resultHandler.accept(sr); } }
@Override public void init() { if ((loginSessionHolder != null) && (loginSessionHolder.getLoginResult() != null)) { final OperationData data = (OperationData) loginSessionHolder.getLoginResult().rootData(); container = JsonUtils.toJsonObject((String)data.getLinks().get("container")); user = JsonUtils.toJsonObject((String)data.getLinks().get("user")); account = JsonUtils.toJsonObject((String)data.getLinks().get("account")); mode = loginSessionHolder.getMode() == null ? RootContextMode.Connected : loginSessionHolder.getMode(); } }
final Map owner = (Map) data.getLinks().get("owner"); final String fullId = (String) owner.get("fullId"); final Task<Void> task = new Task<Void>() {
public static IOperationResult getPrimaryContentFormat(SingleResult res) { final JsonObject q = new JsonObject(); q.addProperty("fullId", res.getData().getAttributes().get("fullId").toString()); q.addProperty("role", res.getData().getAttributes().get("primary").toString()); final List<IOperationResult> t = new ArrayList<>(); final IOperation getPrimaryContentFormat = (IOperation) Services.getBean("GetContentInfoOperation"); getPrimaryContentFormat.doOperation(q, r -> { if (((MultipleResult) r).getData().size() > 0) { final OperationData data = ((MultipleResult) r).getData().get(0); res.getData().getLinks().put("primaryContent", data.getAttributes()); } }, ex -> { ex.printStackTrace(); }); return t.size() > 0 ? (IOperationResult) t.get(0) : null; }
/** * Load data relative to object lifecycle. * * @param applicationContext * @param res * @return */ public static IOperationResult loadAllLifecycleStates(SingleResult res) { JsonObject q = new JsonObject(); q.addProperty("fullId", res.getData().getAttributes().get("fullId").toString()); List<IOperationResult> t = new ArrayList<>(); IOperation getAllLifecycleStatesOperation = (IOperation) Services.getBean("GetAllLifecycleStatesOperation"); getAllLifecycleStatesOperation.doOperation(q, r -> { OperationData data = (OperationData) r.rootData(); if (data != null) { // data.links.lifecycleStates.allStates JsonObject lifecycleStates = new JsonObject(); lifecycleStates.addProperty("allStates", data.getAttributes().get("allStates").toString()); lifecycleStates.addProperty("stateByDenote", data.getAttributes().get("stateByDenote").toString()); lifecycleStates.addProperty("stateByPromote", data.getAttributes().get("stateByPromote").toString()); res.getData().getLinks().put("lifecycleStates", lifecycleStates); } }, ex -> { ex.printStackTrace(); }); return t.size() > 0 ? (IOperationResult) t.get(0) : null; }
public static IOperationResult getAllContentFormat(SingleResult res) { final JsonObject q = new JsonObject(); q.addProperty("fullId", res.getData().getAttributes().get("fullId").toString()); q.addProperty("role", res.getData().getAttributes().get("all").toString()); final List<IOperationResult> t = new ArrayList<>(); final IOperation getPrimaryContentFormat = (IOperation) Services.getBean("GetContentInfoOperation"); getPrimaryContentFormat.doOperation(q, r -> { if (((MultipleResult) r).getData().size() > 0) { for (final OperationData cf : ((MultipleResult) r).getData()) { // primary content if ("primary".equalsIgnoreCase((String) cf.getAttributes().get("role"))) { res.getData().getLinks().put("primaryContent", cf.getAttributes()); } // attachments else { res.getData().getLinks().put((String) cf.getAttributes().get("name"), cf.getAttributes()); } } } }, ex -> { ex.printStackTrace(); }); return t.size() > 0 ? (IOperationResult) t.get(0) : null; }
/** * @{inheritedDoc} */ @Override public void doOperation(JsonObject params, Consumer<IOperationResult> resultHandler, Consumer<Throwable> exHandler) { try { result = CloudServicesLocator.persistableApi.loadBasicRCModel(params); if(lifecycleManagedFeatureArgs.isLoadAllLifecycleStates() && result instanceof SingleResult) { IOperation glsop = (IOperation) Services.getBean("GetLifecycleStatesOperation"); glsop.doOperation(params, res -> { if(res != null) { ((SingleResult)result).getData().getLinks().put("allStates",((SingleResult)res).getData().getAttributes().get("allStates")); ((SingleResult)result).getData().getLinks().put("stateByDenote",((SingleResult)res).getData().getAttributes().get("stateByDenote")); ((SingleResult)result).getData().getLinks().put("stateByPromote",((SingleResult)res).getData().getAttributes().get("stateByPromote")); } }); } resultHandler.accept(result); } catch (Exception e) { if (exHandler != null) { exHandler.accept(e); } } }
PushStructureContentEvent ev = new PushStructureContentEvent.Builder().viewId(StringUtils.isNotBlank(redirectToViewKey) ? (String) formModel.getLinks().get(redirectToViewKey) : pushToView) .model(formModel).modelFullId(modelFullId).build(); controller.dispatchEvent(ev);