/** * @{inheritedDoc} */ @Override public IOperationResult getContentInfo(JsonObject query) { try { final String role = query.get("role").getAsString(); final String fullId = query.get("fullId").getAsString(); final String url = rootUrl.concat(String.format(CONTENT_FORMAT_PATH, fullId, role)); final IOperationResult operationResult = doGet(query, url, MultipleResult.class); if(role.equalsIgnoreCase("primary")) { if(!operationResult.hasBusinessError()) { MultipleResult mr = (MultipleResult) operationResult; // should always be if(mr.getData().size() == 1) { OperationData data = mr.getData().get(0); boolean isnone = "NONE".equalsIgnoreCase((String) data.getAttributes().get("name")); if(isnone) { return IOperationResult.emptyMultipleResult(); } } } } return operationResult; } catch (final Exception e) { e.printStackTrace(); return IOperationResult.generalMultipleResutError(); } }
private IOperationResult doLogin(JsonObject params) { IOperationResult result = CloudServicesLocator.authenticationApi.login(params); if (!result.hasMessage()) { Map object = result.getMetaData(); System.setProperty(SESSION_ID_SYSTEM_PROPERTY_NAME, (String) object.get("session_id")); clientStatus.setLoggedIn(true); clientStatus.setLoggedInSince(LocalDateTime.now()); } return result; }
public String getModelAttribute(IEmaginController controller, String name) { IOperationResult model = (IOperationResult) controller.getModel(); if (model != null) { OperationData data = (OperationData) model.rootData(); if (data != null) { Object d = ReflectionUIUtils.invokeGetterOn(data, name); return d != null ? d.toString() : ""; } } return null; }
protected void dahsboardsLoaded(IOperationResult result) { if (result == null) { dahsboardsLoadError(new NullPointerException()); return; } if (result.hasBusinessError()) { dahsboardsLoadError(new IllegalArgumentException()); return; } if (result instanceof MultipleResult) { MultipleResult multipleResult = (MultipleResult) result; if (multipleResult.hasElements()) { } } dahsboardsLoadError(new IllegalArgumentException()); return; }
/** * Default create success message handler. * * @param operationResult * @param controller */ protected void createSuccess(IOperationResult operationResult) { if (operationResult != null && !operationResult.hasBusinessError()) { resultProperty.set(ActionResult.success()); NodeHelper.showHeaderSuccessCreateMessage(controller); } else { ActionResult ar = new ActionResult .ActionResultBuilder() .operationMessage(operationResult != null ? operationResult.getMessages(): null) .status(ActionResultStatus.ERROR).build(); resultProperty.set(ar); NodeHelper.showHeaderErrorCreateMessage(controller); } }
/** * @param result */ public void handleResult(IOperationResult result) { if (result.hasBusinessError()) { ActionResult actionresult = new ActionResult.ActionResultBuilder().operationMessage(result.getMessages()).status(ActionResultStatus.ERROR).build(); resultProperty.set(actionresult); } else { // set root context of the view to / ILoginSessionHolder loginContext = (ILoginSessionHolder) Services.getBean("LoginSessionHolder"); loginContext.setSessionId((String) result.getMetaData().get("session_id")); loginContext.setLoginResult(result); // redirect to welcome view LoginSuccessEvent loginSuccessEvent = new LoginSuccessEvent(); Services.dispatchEvent(loginSuccessEvent); ViewStructure.instance().listenTo(loginSuccessEvent); ActionResult actionresult = new ActionResult.ActionResultBuilder().operationMessage(result.getMessages()).status(ActionResultStatus.SUCCESS).build(); resultProperty.set(actionresult); } }
@Override public IOperationResult deleteRule(JsonObject query) { String identifier = query.get("identifier").getAsString(); try { String url = rootUrl.concat(String.format(deleteByIdentifier_URI, identifier)); IOperationResult result = doPost(query, url, SingleResult.class); return result; } catch (Exception e) { return IOperationResult.getGeneralSingleResultError(); } }
if(!result.hasBusinessError()) { datas.add(((SingleResult)result).getData()); mr.setData(datas); resultHandler.accept(IOperationResult.emptyMultipleResult()); resultHandler.accept(IOperationResult.emptyMultipleResult());
/** * @{inheritedDoc} */ @Override public IOperationResult loadModel(IEmaginController controller, String compId) { JsonObject model = (JsonObject) controller.getRootStructure().getModel(); String containerFullId = model.get("fullId").getAsString(); JsonObject query = new JsonObject(); query.addProperty("oid", containerFullId); // !! important the loaded must be transformed into combobox model // friendly values. loadContainerTeamTemplatesOperation.doOperation(query, res -> { result = new MultipleResult(); List<OperationData> datas = new ArrayList<>(); ((MultipleResult) result).setData(datas); ((MultipleResult) result).setMetaData(res.getMetaData()); List<OperationData> sourceDatas = (List<OperationData>) res.rootData(); for (OperationData sourceData : sourceDatas) { OperationData modelT = new OperationData.Builder().addAttribute("savedValue", sourceData.getAttributes().get("internalName")) .addAttribute("value", sourceData.getAttributes().get("displayName")).addAttribute("description", sourceData.getAttributes().get("description")).build(); datas.add(modelT); } }); return result; } }
/** * @{inheritedDoc} */ @Override public void deleteAll(OperationCallback callback) { if (callback != null) { if (deleteAllUserNotificationsOperation == null) { callback.onSuccess(IOperationResult.emptyPaginatedData()); return; } getCurrentUserOperation.doOperation(new JsonObject(), res -> { JsonObject query = new JsonObject(); query.addProperty("login", (String) ((OperationData) res.rootData()).getAttributes().get("login")); deleteAllUserNotificationsOperation.doOperation(query, callback.getOnSuccess(), callback.getOnError()); }); } } }
/** * {@inheritDoc} */ @Override public void doOperation(JsonObject params, Consumer<IOperationResult> resultHandler, Consumer<Throwable> exHandler) { resultHandler.accept(IOperationResult.emptyMultipleResult()); } }
/** * @param key * @param base64 */ public static byte[] getImage(String key) { final IOperationResult res = IMAGES_CACHE.get(key); if (res != null) { return (byte[]) res.getMetaData().get(key); } return null; }
/** * @param key * @param val */ public static void addImage(String key, byte[] val) { final IOperationResult res = new SingleResult(); res.addMetaData(key, val); IMAGES_CACHE.put(key, res); }
protected void displayErrorMessages(IOperationResult result) { errorMessagesContainer.getChildren().clear(); List<OperationMessage> messages = result.getMessages(); for(OperationMessage message: messages) { String details = message.getDetail(); Label label = new Label(details); label.getStyleClass().add("form-inline-error-message"); errorMessagesContainer.getChildren().add(label); } }
/** * {@inheritDoc} */ @Override public IOperationResult loadModel(IEmaginController controller, String componentId) { IOperationResult operationResult = new SingleResult(); OperationData datato = new OperationData(); operationResult.setData(datato); OperationData datafrom = ((AbstractViewController) controller).getStructureContent().getFormModelData(); for (Object key : datafrom.getAttributes().keySet()) { datato.getAttributes().put((String) key, datafrom.getAttributes().get(key)); } controller.setModel(operationResult); return operationResult; }
/** * {@inheritDoc} */ @Override public void doOperation(JsonObject params, Consumer<IOperationResult> resultHandler, Consumer<Throwable> exHandler) { try { SingleResult currentUser = (SingleResult) PlatformOperationsCache.get(GetCurrentUserOperation.CACHE_KEY, CachedObjectType.OPERATION_RESULT); String userLogin = (String) currentUser.getData().getAttributes().get("nickName"); String key = params.get("key").getAsString(); params.addProperty("userLogin", userLogin); IOperationResult result = CloudServicesLocator.preferenceApi.setPreference(params); if(!result.hasBusinessError()) { GetPreferenceValueOperation.CACHE.put(key, ((SingleResult)result).getData()); resultHandler.accept(result); } } catch (Exception e) { exHandler.accept(e); } } }
protected void createSuccess(IOperationResult operationResult) { if (!operationResult.hasBusinessError()) { sourceController.hide(); sourceController.hideProcessingPane(); NodeHelper.showHeaderSuccessCreateMessage(sourceController); } // error else { NodeHelper.showHeaderErrorCreateMessage(sourceController); sourceController.hideProcessingPane(); sourceController.show(); ActionResult ar = new ActionResult.ActionResultBuilder().operationMessage(operationResult.getMessages()).status(ActionResultStatus.ERROR).build(); resultProperty.set(ar); } }
@Override public IOperationResult deleteAllNotifications(JsonObject query) throws OperationException { try { Object login = query.get("login"); String url = rootUrl.concat(String.format(DELETE_ALL_URI, login)); IOperationResult result = doDelete(query, url, SingleResult.class); return result; } catch (Exception e) { e.printStackTrace(); return IOperationResult.getGeneralSingleResultError(); } }
/** * @{inheritedDoc} */ @Override public void markAllReaden(OperationCallback callback) { if (callback != null) { if (markAllNotificationsReaden == null) { callback.onSuccess(IOperationResult.emptyPaginatedData()); return; } getCurrentUserOperation.doOperation(new JsonObject(), res -> { JsonObject query = new JsonObject(); query.addProperty("login", (String) ((OperationData) res.rootData()).getAttributes().get("login")); markAllNotificationsReaden.doOperation(query, callback.getOnSuccess(), callback.getOnError()); }); } }