protected SearchNode buildSearchModel(AdminComponent admin) { SearchNode res = new SearchNode(); res.setLongName(admin.getLongName()); DataElementTransferObject dtoItem; if (admin instanceof DataElementTransferObject) { dtoItem = (DataElementTransferObject) admin; res.setOwnedBy(dtoItem.getContextName()); res.setPreferredQuestionText(dtoItem.getLongCDEName()); } res.setRegistrationStatus(admin.getRegistrationStatus()); res.setWorkflowStatus(admin.getAslName()); res.setPublicId(admin.getPublicId()); res.setVersion("" + admin.getVersion()); res.setDeIdseq(admin.getIdseq()); // printAdminComponent(admin); return res; }
public DataElementTransferObject toDataElement(DataElementModel deModel) { // this is the code modified from v.4.0.5 DTOTransformer DTOTransformer.toDataElement // we need to assign all the data for compatibility DataElementTransferObject de = new DataElementTransferObject(); if (deModel == null) return de; de.setDeIdseq(deModel.getDeIdseq().trim()); de.setPreferredName(deModel.getPreferredName()); de.setPublicId(deModel.getPublicId()); de.setLongName(deModel.getLongName()); de.setPreferredDefinition(deModel.getPreferredDefinition()); ValueDomainModel vdm = deModel.getValueDomainModel(); // This was commented in v.4.0.5 I keep in here for consistency // List values = toPermissibleValueList(vd); // vd.setValidValues(values); de.setValueDomain(buildValueDomainTransfer(vdm)); // FIXME implement // ContextModel cm = deModel.getContext(); de.setContext(null); deModel.getContext(); // I believe this is the data stored which we need to the Question/Doc Text/Preferred Question // Text de.setLongCDEName(deModel.getQuestion()); de.setAslName(deModel.getAslName()); de.setVersion(deModel.getVersion()); de.setContextName(deModel.getContextName()); de.setUsingContexts(deModel.getUsingContexts()); de.setRegistrationStatus(deModel.getRegistrationStatus()); return de; }
/* (non-Javadoc) * @see gov.nih.nci.cadsr.cdecart.CdeCartUtilInterface#addToCart(javax.servlet.http.HttpSession, java.lang.String, java.util.List) */ @Override public void addToCart(HttpSession mySession, String principalName, List<String> cdeIds) throws ObjectCartException, AutheticationFailureException { if ((cdeIds == null) || (mySession == null)) { log.debug("Nothing to save"); return; } CDECart sessionCart = (CDECart) mySession.getAttribute(CaDSRConstants.CDE_CART); if (sessionCart == null) { sessionCart = findCdeCart(mySession, principalName); } String userName = principalName; // we shall be after login here, and userName is never null if (userName == null) { log.error("........No user found in session in addToCart"); throw new AutheticationFailureException("Authenticated user not found in the session"); } try { if (ocURL == null) { // try to get it again for a chance fixed in DB ToolOptionsModel cdeCartOptionsModel = toolOptionsDAO.getToolOptionsByToolNameAndProperty("ObjectCartAPI", "URL"); if (cdeCartOptionsModel != null) { ocURL = cdeCartOptionsModel.getValue(); } if (ocURL == null) { log.warn("Cannot get a value of ObjectCart URL from the system configuration"); } } ObjectCartClient ocClient = null; if (!ocURL.equals("")) ocClient = new ObjectCartClient(ocURL); else ocClient = new ObjectCartClient(); CDECart userCart = new CDECartOCImpl(ocClient, userName, CaDSRConstants.CDE_CART); List<DataElementModel> deModelList = dataElementDAO.getCdeByDeIdseqList(cdeIds); Collection<DataElementTransferObject> addCandidates = buildCartTransferObjects(deModelList); Collection<CDECartItem> items = new ArrayList<CDECartItem>(); for (DataElementTransferObject deto : addCandidates) { CDECartItem cartItem = sessionCart.findDataElement(deto.getIdseq()); if (cartItem == null) { CDECartItem cdeItem = new CDECartItemTransferObject(); cdeItem.setPersistedInd(false); // we have IDs only for items to save cdeItem.setItem(deto); items.add(cdeItem); } else { cartItem.setPersistedInd(true); items.add(cartItem); } } userCart.mergeDataElements(items); } catch (ObjectCartException oce) { log.error("Exception on cdeCart.getDataElements", oce); throw oce; } }