List of usage examples for java.util TreeMap values
public Collection<V> values()
From source file:org.mule.devkit.doclet.ClassInfo.java
public FieldInfo[] fields() { if (mFields == null) { int N;//from ww w. j av a2s . co m TreeMap<String, FieldInfo> all = new TreeMap<String, FieldInfo>(); ClassInfo[] interfaces = getInterfaces(); N = interfaces.length; for (int i = 0; i < N; i++) { addFields(interfaces[i], all); } ClassInfo superclass = superclass(); if (superclass != null) { addFields(superclass, all); } FieldInfo[] fields = selfFields(); N = fields.length; for (int i = 0; i < N; i++) { FieldInfo f = fields[i]; if (!f.isHidden()) { String key = f.name(); all.put(key, f); } } mFields = all.values().toArray(new FieldInfo[0]); } return mFields; }
From source file:org.mule.devkit.doclet.ClassInfo.java
/** * Turns into the main class page/* w ww . ja va 2 s.co m*/ */ public void makeHDF(Data data) { int i, j, n; String name = name(); String qualified = qualifiedName(); AttributeInfo[] selfAttributes = selfAttributes(); MethodInfo[] methods = selfMethods(); FieldInfo[] fields = selfFields(); FieldInfo[] enumConstants = enumConstants(); MethodInfo[] ctors = constructors(); ClassInfo[] inners = innerClasses(); // class name mTypeInfo.makeHDF(data, "class.type"); mTypeInfo.makeQualifiedHDF(data, "class.qualifiedType"); data.setValue("class.name", name); data.setValue("class.qualified", qualified); if (isProtected()) { data.setValue("class.scope", "protected"); } else if (isPublic()) { data.setValue("class.scope", "public"); } if (isStatic()) { data.setValue("class.static", "static"); } if (isFinal()) { data.setValue("class.final", "final"); } if (isAbstract() && !isInterface()) { data.setValue("class.abstract", "abstract"); } // module info data.setValue("class.moduleName", this.moduleName()); data.setValue("class.moduleNamespace", this.moduleNamespace()); data.setValue("class.moduleSchemaLocation", this.moduleSchemaLocation()); data.setValue("class.moduleSchemaPath", this.moduleSchemaPath()); try { data.setValue("class.moduleSchema", StringEscapeUtils.escapeHtml4(FileUtils.readFileToString(new File( "../../../target/generated-sources/mule/META-INF/mule-" + this.moduleName() + ".xsd")))); } catch (IOException ioe) { Errors.error(Errors.IO_ERROR, position(), "Error reading schema for module " + this.moduleName()); } data.setValue("class.moduleVersion", this.moduleVersion()); data.setValue("class.moduleMinMuleVersion", this.moduleMinMuleVersion()); data.setValue("class.moduleSessionAware", Boolean.toString(this.moduleSessionAware())); data.setValue("class.moduleOAuthAware", Boolean.toString(this.oauthAware())); if (moduleSessionAware()) { //ParameterInfo.makeHDF(data, "class.moduleSessionVariables", mModuleConnectVariables, false, mModuleConnectVariablesTypes); ParamTagInfo.makeHDF(data, "class.moduleConnectVariables", mModuleConnectVariables); } // class info String kind = kind(); if (kind != null) { data.setValue("class.kind", kind); } data.setValue("class.since.key", SinceTagger.keyForName(getSince())); data.setValue("class.since.name", getSince()); setFederatedReferences(data, "class"); // the containing package -- note that this can be passed to type_link, // but it also contains the list of all of the packages containingPackage().makeClassLinkListHDF(data, "class.package"); // inheritance hierarchy Vector<ClassInfo> superClasses = new Vector<ClassInfo>(); superClasses.add(this); ClassInfo supr = superclass(); while (supr != null) { superClasses.add(supr); supr = supr.superclass(); } n = superClasses.size(); for (i = 0; i < n; i++) { supr = superClasses.elementAt(n - i - 1); supr.asTypeInfo().makeQualifiedHDF(data, "class.inheritance." + i + ".class"); supr.asTypeInfo().makeHDF(data, "class.inheritance." + i + ".short_class"); j = 0; for (TypeInfo t : supr.interfaceTypes()) { t.makeHDF(data, "class.inheritance." + i + ".interfaces." + j); j++; } } // class description TagInfo.makeHDF(data, "class.descr", inlineTags()); TagInfo.makeHDF(data, "class.seeAlso", comment().seeTags()); TagInfo.makeHDF(data, "class.deprecated", deprecatedTags()); // known subclasses TreeMap<String, ClassInfo> direct = new TreeMap<String, ClassInfo>(); TreeMap<String, ClassInfo> indirect = new TreeMap<String, ClassInfo>(); ClassInfo[] all = Converter.rootClasses(); for (ClassInfo cl : all) { if (cl.superclass() != null && cl.superclass().equals(this)) { direct.put(cl.name(), cl); } else if (cl.isDerivedFrom(this)) { indirect.put(cl.name(), cl); } } // direct i = 0; for (ClassInfo cl : direct.values()) { if (cl.checkLevel()) { cl.makeShortDescrHDF(data, "class.subclasses.direct." + i); } i++; } // indirect i = 0; for (ClassInfo cl : indirect.values()) { if (cl.checkLevel()) { cl.makeShortDescrHDF(data, "class.subclasses.indirect." + i); } i++; } // hide special cases if ("java.lang.Object".equals(qualified) || "java.io.Serializable".equals(qualified)) { data.setValue("class.subclasses.hidden", "1"); } else { data.setValue("class.subclasses.hidden", "0"); } // nested classes i = 0; for (ClassInfo inner : inners) { if (inner.checkLevel()) { inner.makeShortDescrHDF(data, "class.inners." + i); } i++; } // enum constants i = 0; for (FieldInfo field : enumConstants) { field.makeHDF(data, "class.enumConstants." + i); i++; } // constants i = 0; for (FieldInfo field : fields) { if (field.isConstant()) { field.makeHDF(data, "class.constants." + i); i++; } } // fields i = 0; for (FieldInfo field : fields) { if (!field.isConstant()) { field.makeHDF(data, "class.fields." + i); i++; } } // constants i = 0; for (FieldInfo field : mAllSelfFields) { if (field.isConfigurable()) { field.makeHDF(data, "class.config." + i); i++; } } // public constructors i = 0; for (MethodInfo ctor : ctors) { if (ctor.isPublic()) { ctor.makeHDF(data, "class.ctors.public." + i); i++; } } // protected constructors if (Doclava.checkLevel(Doclava.SHOW_PROTECTED)) { i = 0; for (MethodInfo ctor : ctors) { if (ctor.isProtected()) { ctor.makeHDF(data, "class.ctors.protected." + i); i++; } } } // package private constructors if (Doclava.checkLevel(Doclava.SHOW_PACKAGE)) { i = 0; for (MethodInfo ctor : ctors) { if (ctor.isPackagePrivate()) { ctor.makeHDF(data, "class.ctors.package." + i); i++; } } } // private constructors if (Doclava.checkLevel(Doclava.SHOW_PRIVATE)) { i = 0; for (MethodInfo ctor : ctors) { if (ctor.isPrivate()) { ctor.makeHDF(data, "class.ctors.private." + i); i++; } } } // public methods i = 0; for (MethodInfo method : methods) { if (method.isPublic()) { method.makeHDF(data, "class.methods.public." + i); i++; } } // protected methods if (Doclava.checkLevel(Doclava.SHOW_PROTECTED)) { i = 0; for (MethodInfo method : methods) { if (method.isProtected()) { method.makeHDF(data, "class.methods.protected." + i); i++; } } } // package private methods if (Doclava.checkLevel(Doclava.SHOW_PACKAGE)) { i = 0; for (MethodInfo method : methods) { if (method.isPackagePrivate()) { method.makeHDF(data, "class.methods.package." + i); i++; } } } // private methods if (Doclava.checkLevel(Doclava.SHOW_PRIVATE)) { i = 0; for (MethodInfo method : methods) { if (method.isPrivate()) { method.makeHDF(data, "class.methods.private." + i); i++; } } } // processors i = 0; for (MethodInfo method : methods) { if (method.isProcessor()) { method.makeHDF(data, "class.methods.processor." + i); i++; } } // source i = 0; for (MethodInfo method : methods) { if (method.isSource()) { method.makeHDF(data, "class.methods.source." + i); i++; } } // transformer i = 0; for (MethodInfo method : methods) { if (method.isTransformer()) { method.makeHDF(data, "class.methods.transformer." + i); i++; } } // xml attributes i = 0; for (AttributeInfo attr : selfAttributes) { if (attr.checkLevel()) { attr.makeHDF(data, "class.attrs." + i); i++; } } // inherited methods Set<ClassInfo> interfaces = new TreeSet<ClassInfo>(); addInterfaces(getInterfaces(), interfaces); ClassInfo cl = superclass(); i = 0; while (cl != null) { addInterfaces(cl.getInterfaces(), interfaces); makeInheritedHDF(data, i, cl); cl = cl.superclass(); i++; } for (ClassInfo iface : interfaces) { makeInheritedHDF(data, i, iface); i++; } }
From source file:de.juwimm.cms.remote.ContentServiceSpringImpl.java
/** * @see de.juwimm.cms.remote.ContentServiceSpring#getAllContentVersions(java.lang.Integer) *//* w w w . java 2s .c om*/ @Override protected ContentVersionValue[] handleGetAllContentVersions(Integer contentId) throws UserException { try { ContentHbm content = super.getContentHbmDao().load(contentId); Collection<ContentVersionHbm> coll = content.getContentVersions(); Iterator<ContentVersionHbm> it = coll.iterator(); TreeMap<Integer, ContentVersionHbm> tm = new TreeMap<Integer, ContentVersionHbm>(); while (it.hasNext()) { ContentVersionHbm cvd = it.next(); if (!cvd.getVersion().equals("PUBLS")) { tm.put(new Integer(cvd.getVersion()), cvd); } } it = tm.values().iterator(); int siz = tm.values().size(); ContentVersionValue[] arr = new ContentVersionValue[siz]; for (int i = 0; i < siz; i++) { ContentVersionHbm cv = it.next(); arr[i] = getContentVersionHbmDao().getDao(cv); if (i == (siz - 1)) { arr[i].setVersionComment(arr[i].getCreator() + " (" + DateConverter.getSql2String(new Date(arr[i].getCreateDate())) + ")"); } else { arr[i].setVersionComment(arr[i].getVersion() + " - " + arr[i].getCreator() + " (" + DateConverter.getSql2String(new Date(arr[i].getCreateDate())) + ")"); } arr[i].setText(null); } return arr; } catch (Exception e) { throw new UserException(e.getMessage()); } }
From source file:org.esa.nest.gpf.SliceAssemblyOp.java
private Product[] determineSliceProducts() throws Exception { if (sourceProducts.length < 2) { throw new Exception("Slice assembly requires at least two consecutive slice products"); }//ww w . j a va 2s .c o m final TreeMap<Integer, Product> productSet = new TreeMap<>(); for (Product srcProduct : sourceProducts) { final MetadataElement origMetaRoot = AbstractMetadata.getOriginalProductMetadata(srcProduct); final MetadataElement generalProductInformation = getGeneralProductInformation(origMetaRoot); if (!isSliceProduct(generalProductInformation)) { throw new Exception(srcProduct.getName() + " is not a slice product"); } final int totalSlices = generalProductInformation.getAttributeInt("totalSlices"); final int sliceNumber = generalProductInformation.getAttributeInt("sliceNumber"); //System.out.println("SliceAssemblyOp.determineSliceProducts: totalSlices = " + totalSlices + "; slice product name = " + srcProduct.getName() + "; prod type = " + srcProduct.getProductType() + "; sliceNumber = " + sliceNumber); productSet.put(sliceNumber, srcProduct); } //check if consecutive Integer prev = productSet.firstKey(); // Note that "The set's iterator returns the keys in ascending order". for (Integer i : productSet.keySet()) { if (!i.equals(prev)) { if (!prev.equals(i - 1)) { throw new Exception("Products are not consecutive slices"); } prev = i; } } // Note that "If productSet makes any guarantees as to what order its elements // are returned by its iterator, toArray() must return the elements in // the same order". return productSet.values().toArray(new Product[productSet.size()]); }
From source file:de.juwimm.cms.remote.ContentServiceSpringImpl.java
/** * @see de.juwimm.cms.remote.ContentServiceSpring#getAllContentVersionsId(java.lang.Integer) *//*from w w w .j a v a 2 s .c om*/ @Override protected Integer[] handleGetAllContentVersionsId(Integer contentId) throws Exception { try { ContentHbm content = super.getContentHbmDao().load(contentId); Collection coll = content.getContentVersions(); Iterator it = coll.iterator(); TreeMap<Integer, ContentVersionHbm> tm = new TreeMap<Integer, ContentVersionHbm>(); while (it.hasNext()) { ContentVersionHbm cvd = (ContentVersionHbm) it.next(); if (!cvd.getVersion().equals("PUBLS")) { tm.put(new Integer(cvd.getVersion()), cvd); } } it = tm.values().iterator(); int siz = tm.values().size(); Integer[] arr = new Integer[siz]; for (int i = 0; i < siz; i++) { arr[i] = ((ContentVersionHbm) it.next()).getContentVersionId(); } return arr; } catch (Exception e) { throw new UserException(e.getMessage()); } }
From source file:org.commoncrawl.service.listcrawler.CrawlList.java
private static void validateListCode(final File dataDirectory, long listId) throws IOException { final String urlList[] = new String[] { "http://www.yahoo.com/1", "http://www.google.com/1", "http://www.cnn.com/1", "http://www.yahoo.com/2", "http://www.google.com/2", "http://www.cnn.com/2" }; File tempFile = File.createTempFile("CrawlList", "validateListInit"); File localTempFile = new File(dataDirectory, tempFile.getName()); generateTestURLFile(localTempFile, urlList); final TreeMap<String, URLFP> urlToFPMap = new TreeMap<String, URLFP>(); final TreeMap<URLFP, String> urlFPToString = new TreeMap<URLFP, String>(); for (String url : urlList) { URLFP fp = URLUtils.getURLFPFromURL(url, true); urlToFPMap.put(url, fp);/*from ww w.j a v a 2 s. c om*/ urlFPToString.put(fp, url); } final TreeMap<URLFP, ProxyCrawlHistoryItem> itemsToMarkComplete = new TreeMap<URLFP, ProxyCrawlHistoryItem>(); ProxyCrawlHistoryItem item1 = new ProxyCrawlHistoryItem(); item1.setCrawlStatus(CrawlURL.FailureReason.RobotsExcluded); item1.setOriginalURL(urlList[1]); ProxyCrawlHistoryItem item2 = new ProxyCrawlHistoryItem(); item2.setCrawlStatus(0); item2.setOriginalURL(urlList[3]); item2.setHttpResultCode(301); item2.setRedirectURL("http://www.yahoo.com/3"); item2.setRedirectStatus(0); item2.setRedirectHttpResult(200); ProxyCrawlHistoryItem item3 = new ProxyCrawlHistoryItem(); item3.setCrawlStatus(0); item3.setOriginalURL(urlList[4]); item3.setHttpResultCode(301); item3.setRedirectURL("http://www.google.com/3"); item3.setRedirectStatus(CrawlURL.FailureReason.IOException); itemsToMarkComplete.put(urlToFPMap.get(item1.getOriginalURL()), item1); itemsToMarkComplete.put(urlToFPMap.get(item2.getOriginalURL()), item2); itemsToMarkComplete.put(urlToFPMap.get(item3.getOriginalURL()), item3); final Set<URLFP> itemsToMarkCompleteFPSet = itemsToMarkComplete.keySet(); final Set<URLFP> itemsNotMarked = new TreeSet<URLFP>(urlToFPMap.values()); itemsNotMarked.removeAll(itemsToMarkCompleteFPSet); CrawlHistoryStorage storage = new CrawlHistoryStorage() { @Override public void syncList(long listId, TreeSet<URLFP> matchCriteria, ItemUpdater targetList) throws IOException { for (URLFP matchItem : matchCriteria) { if (itemsToMarkCompleteFPSet.contains(matchItem)) { targetList.updateItemState(matchItem, itemsToMarkComplete.get(matchItem)); } } } @Override public File getLocalDataDir() { return dataDirectory; } }; CrawlList list1 = new CrawlList(storage, listId, localTempFile, 0); for (int pass = 0; pass < 2; ++pass) { CrawlList list = null; if (pass == 0) { System.out.println("Pass 0 - Initialize from URLList"); list = list1; } else { System.out.println("Pass 1 - Initialize from OnDisk Data"); list = new CrawlList(storage, listId); } // iterate fingerprints for (URLFP fingerprint : urlToFPMap.values()) { ProxyCrawlHistoryItem itemRetrieved = list.getHistoryItemFromURLFP(fingerprint); if (itemsToMarkCompleteFPSet.contains(fingerprint)) { ProxyCrawlHistoryItem itemExpected = itemsToMarkComplete.get(fingerprint); Assert.assertTrue(itemExpected.equals(itemRetrieved)); } else { Assert.assertTrue(itemRetrieved.getOriginalURL().equals(urlFPToString.get(fingerprint)) && !itemRetrieved.isFieldDirty(ProxyCrawlHistoryItem.Field_CRAWLSTATUS) && !itemRetrieved.isFieldDirty(ProxyCrawlHistoryItem.Field_HTTPRESULTCODE) && !itemRetrieved.isFieldDirty(ProxyCrawlHistoryItem.Field_REDIRECTHTTPRESULT) && !itemRetrieved.isFieldDirty(ProxyCrawlHistoryItem.Field_REDIRECTSTATUS) && !itemRetrieved.isFieldDirty(ProxyCrawlHistoryItem.Field_REDIRECTURL)); } } } // validate string code does not update when strings have not changed item3.setRedirectStatus(0); item3.setRedirectHttpResult(200); long variableDataLength = list1._variableDataFile.length(); long fixedDataLength = list1._fixedDataFile.length(); list1.updateItemState(urlToFPMap.get(item3.getOriginalURL()), item3); Assert.assertTrue(fixedDataLength == list1._fixedDataFile.length()); Assert.assertTrue(variableDataLength == list1._variableDataFile.length()); list1.queueUnCrawledItems(new CrawlQueueLoader() { @Override public void queueURL(URLFP urlfp, String url) { Assert.assertTrue(itemsNotMarked.contains(urlfp)); Assert.assertTrue(urlFPToString.get(urlfp).equals(url)); } @Override public void flush() { // TODO Auto-generated method stub } }); }
From source file:org.mule.devkit.doclet.ClassInfo.java
public MethodInfo[] methods() { if (mMethods == null) { TreeMap<String, MethodInfo> all = new TreeMap<String, MethodInfo>(); ClassInfo[] ifaces = getInterfaces(); for (ClassInfo iface : ifaces) { if (iface != null) { MethodInfo[] inhereted = iface.methods(); for (MethodInfo method : inhereted) { String key = method.getHashableName(); all.put(key, method); }//from w ww .j a va2 s. co m } } ClassInfo superclass = superclass(); if (superclass != null) { MethodInfo[] inhereted = superclass.methods(); for (MethodInfo method : inhereted) { String key = method.getHashableName(); all.put(key, method); } } MethodInfo[] methods = selfMethods(); for (MethodInfo method : methods) { String key = method.getHashableName(); all.put(key, method); } mMethods = all.values().toArray(new MethodInfo[all.size()]); Arrays.sort(mMethods, MethodInfo.comparator); } return mMethods; }
From source file:org.jahia.admin.sites.ManageSites.java
/** * Display page to let user choose a set of templates. * * @param request Servlet request./* w ww . ja v a2s.c om*/ * @param response Servlet response. * @param session HttpSession object. */ private void displayTemplateSetChoice(HttpServletRequest request, HttpServletResponse response, HttpSession session) throws IOException, ServletException { try { logger.debug("Display template set choice started "); // retrieve previous form values... String jahiaDisplayMessage = (String) request.getAttribute(CLASS_NAME + "jahiaDisplayMessage"); // set default values... if (jahiaDisplayMessage == null) { jahiaDisplayMessage = Jahia.COPYRIGHT; } String selectedTmplSet = (String) request.getAttribute("selectedTmplSet"); TreeMap<String, JCRNodeWrapper> orderedTemplateSets = getTemplatesSets(); // try to select the default set if not selected if (selectedTmplSet == null) { selectedTmplSet = SettingsBean.getInstance().getPropertiesFile() .getProperty("default_templates_set", orderedTemplateSets.firstKey()); } JCRNodeWrapper selectedPackage = selectedTmplSet != null && orderedTemplateSets.containsKey(selectedTmplSet) ? orderedTemplateSets.get(selectedTmplSet) : orderedTemplateSets.get(orderedTemplateSets.firstKey()); request.setAttribute("selectedTmplSet", selectedTmplSet); request.setAttribute("tmplSets", orderedTemplateSets.values()); request.setAttribute("modules", getModulesOfType(JahiaTemplateManagerService.MODULE_TYPE_MODULE).values()); request.setAttribute("jahiApps", getModulesOfType(JahiaTemplateManagerService.MODULE_TYPE_JAHIAPP).values()); request.setAttribute("selectedModules", jParams.getParameterValues("selectedModules")); request.setAttribute("selectedPackage", selectedPackage); Locale currentLocale = (Locale) session.getAttribute(ProcessingContext.SESSION_LOCALE); if (currentLocale == null) { currentLocale = request.getLocale(); } Locale selectedLocale = (Locale) session.getAttribute(CLASS_NAME + "selectedLocale"); if (selectedLocale == null) { selectedLocale = LanguageCodeConverters .languageCodeToLocale(Jahia.getSettings().getDefaultLanguageCode()); } session.setAttribute(CLASS_NAME + "selectedLocale", selectedLocale); request.setAttribute("selectedLocale", selectedLocale); request.setAttribute("currentLocale", currentLocale); logger.debug("Nb template set found " + orderedTemplateSets.size()); // redirect... JahiaAdministration.doRedirect(request, response, session, JSP_PATH + "site_choose_template_set.jsp"); // set default values... session.setAttribute(CLASS_NAME + "jahiaDisplayMessage", Jahia.COPYRIGHT); } catch (RepositoryException e) { throw new ServletException(e); } }
From source file:de.juwimm.cms.remote.ContentServiceSpringImpl.java
/** * If this page has more than ContentServiceSpringImpl.MAX_NO_OF_CONTENT_VERSIONS_PER_PAGE contentVersions, the oldest ones are deleted, the rest gets renumbered. An existing PUBLS-Version is * conserved./*from ww w. j a va2s .c om*/ */ private void removeSpareContentVersions(Integer contentId) { try { Collection allContentVersions = super.getContentHbmDao().load(contentId).getContentVersions(); if (allContentVersions != null && allContentVersions.size() > ContentServiceSpringImpl.MAX_NO_OF_CONTENT_VERSIONS_PER_PAGE) { Iterator<ContentVersionHbm> it = allContentVersions.iterator(); TreeMap<Integer, ContentVersionHbm> tm = new TreeMap<Integer, ContentVersionHbm>(); while (it.hasNext()) { ContentVersionHbm cvd = it.next(); if (!cvd.getVersion().equals("PUBLS")) { tm.put(new Integer(cvd.getVersion()), cvd); } } List<Integer> cvList2Delete = new ArrayList<Integer>(); List<ContentVersionHbm> cvList = new ArrayList<ContentVersionHbm>(); it = tm.values().iterator(); while (it.hasNext()) { cvList.add(it.next()); } int firstCoolIndex = tm.values().size() - ContentServiceSpringImpl.MAX_NO_OF_CONTENT_VERSIONS_PER_PAGE; int currentIndex = 1; for (int i = 0; i < cvList.size(); i++) { ContentVersionHbm current = cvList.get(i); if (i < firstCoolIndex) { cvList2Delete.add(current.getContentVersionId()); } else { current.setVersion(Integer.toString(currentIndex++)); } } Iterator<Integer> delIt = cvList2Delete.iterator(); while (delIt.hasNext()) { Integer currContentVersionId = delIt.next(); if (log.isDebugEnabled()) log.debug("Content: " + contentId + " Contentversion to delete: " + currContentVersionId); super.getContentVersionHbmDao().remove(currContentVersionId); } } } catch (Exception e) { log.error("Error removing spare ContentVersions: " + e.getMessage(), e); } }
From source file:org.oscarehr.PMmodule.web.ClientManagerAction.java
private void setEditAttributes(ActionForm form, HttpServletRequest request, String demographicNo) { DynaActionForm clientForm = (DynaActionForm) form; LoggedInInfo loggedInInfo = LoggedInInfo.loggedInInfo.get(); Integer facilityId = loggedInInfo.currentFacility.getId(); ClientManagerFormBean tabBean = (ClientManagerFormBean) clientForm.get("view"); Integer demographicId = Integer.valueOf(demographicNo); request.setAttribute("id", demographicNo); request.setAttribute("client", clientManager.getClientByDemographicNo(demographicNo)); String providerNo = getProviderNo(request); // program domain List<Program> programDomain = new ArrayList<Program>(); for (Iterator<?> i = providerManager.getProgramDomain(providerNo).iterator(); i.hasNext();) { ProgramProvider programProvider = (ProgramProvider) i.next(); programDomain.add(programManager.getProgram(programProvider.getProgramId())); }/*from ww w .jav a2s . co m*/ request.setAttribute("programDomain", programDomain); // check role permission HttpSession se = request.getSession(); List admissions = admissionManager.getCurrentAdmissions(Integer.valueOf(demographicNo)); for (Iterator it = admissions.iterator(); it.hasNext();) { Admission admission = (Admission) it.next(); String inProgramId = String.valueOf(admission.getProgramId()); String inProgramType = admission.getProgramType(); if ("service".equalsIgnoreCase(inProgramType)) { se.setAttribute("performDischargeService", new Boolean(caseManagementManager .hasAccessRight("perform discharges", "access", providerNo, demographicNo, inProgramId))); se.setAttribute("performAdmissionService", new Boolean(caseManagementManager .hasAccessRight("perform admissions", "access", providerNo, demographicNo, inProgramId))); } else if ("bed".equalsIgnoreCase(inProgramType)) { se.setAttribute("performDischargeBed", new Boolean(caseManagementManager .hasAccessRight("perform discharges", "access", providerNo, demographicNo, inProgramId))); se.setAttribute("performAdmissionBed", new Boolean(caseManagementManager .hasAccessRight("perform admissions", "access", providerNo, demographicNo, inProgramId))); se.setAttribute("performBedAssignments", new Boolean(caseManagementManager.hasAccessRight("perform bed assignments", "access", providerNo, demographicNo, inProgramId))); } } // tab override - from survey module String tabOverride = (String) request.getAttribute("tab.override"); if (tabOverride != null && tabOverride.length() > 0) { tabBean.setTab(tabOverride); } if (tabBean.getTab().equals("Summary")) { /* survey module */ request.setAttribute("survey_list", surveyManager.getAllFormsForCurrentProviderAndCurrentFacility()); request.setAttribute("surveys", surveyManager.getFormsForCurrentProviderAndCurrentFacility(demographicNo)); // request.setAttribute("admissions", admissionManager.getCurrentAdmissions(Integer.valueOf(demographicNo))); // only allow bed/service programs show up.(not external program) List<Admission> currentAdmissionList = admissionManager.getCurrentAdmissionsByFacility(demographicId, facilityId); ArrayList<AdmissionForDisplay> bedServiceList = new ArrayList<AdmissionForDisplay>(); for (Admission admission1 : currentAdmissionList) { if (!"External".equalsIgnoreCase(programManager.getProgram(admission1.getProgramId()).getType())) { bedServiceList.add(new AdmissionForDisplay(admission1)); } } addRemoteAdmissions(bedServiceList, demographicId); request.setAttribute("admissions", bedServiceList); Intake mostRecentQuickIntake = genericIntakeManager .getMostRecentQuickIntakeByFacility(Integer.valueOf(demographicNo), facilityId); request.setAttribute("mostRecentQuickIntake", mostRecentQuickIntake); HealthSafety healthsafety = healthSafetyManager .getHealthSafetyByDemographic(Long.valueOf(demographicNo)); request.setAttribute("healthsafety", healthsafety); request.setAttribute("referrals", getReferralsForSummary(Integer.parseInt(demographicNo), facilityId)); // FULL OCAN Staff/Client Assessment OcanStaffForm ocanStaffForm = ocanStaffFormDao.findLatestByFacilityClient(facilityId, Integer.valueOf(demographicNo), "FULL"); if (ocanStaffForm != null) { if (ocanStaffForm.getAssessmentStatus() != null && ocanStaffForm.getAssessmentStatus().equals("In Progress")) request.setAttribute("ocanStaffForm", ocanStaffForm); } else { request.setAttribute("ocanStaffForm", null); } // SELF+CORE OCAN Staff/Client Assessment OcanStaffForm selfOcanStaffForm = ocanStaffFormDao.findLatestByFacilityClient(facilityId, Integer.valueOf(demographicNo), "SELF"); if (selfOcanStaffForm != null) { if (selfOcanStaffForm.getAssessmentStatus() != null && selfOcanStaffForm.getAssessmentStatus().equals("In Progress")) { request.setAttribute("selfOcanStaffForm", selfOcanStaffForm); } } else { request.setAttribute("selfOcanStaffForm", null); } // CORE OCAN Staff/Client Assessment OcanStaffForm coreOcanStaffForm = ocanStaffFormDao.findLatestByFacilityClient(facilityId, Integer.valueOf(demographicNo), "CORE"); if (coreOcanStaffForm != null) { if (coreOcanStaffForm.getAssessmentStatus() != null && coreOcanStaffForm.getAssessmentStatus().equals("In Progress")) { request.setAttribute("coreOcanStaffForm", coreOcanStaffForm); } } else { request.setAttribute("coreOcanStaffForm", null); } // CDS CdsClientForm cdsClientForm = cdsClientFormDao.findLatestByFacilityClient(facilityId, Integer.valueOf(demographicNo)); request.setAttribute("cdsClientForm", cdsClientForm); } /* history */ if (tabBean.getTab().equals("History")) { ArrayList<AdmissionForDisplay> allResults = new ArrayList<AdmissionForDisplay>(); List<Admission> addLocalAdmissions = admissionManager.getAdmissionsByFacility(demographicId, facilityId); for (Admission admission : addLocalAdmissions) allResults.add(new AdmissionForDisplay(admission)); addRemoteAdmissions(allResults, demographicId); request.setAttribute("admissionHistory", allResults); request.setAttribute("referralHistory", getReferralsForHistory(demographicId, facilityId)); } List<?> currentAdmissions = admissionManager.getCurrentAdmissions(Integer.valueOf(demographicNo)); for (int x = 0; x < currentAdmissions.size(); x++) { Admission admission = (Admission) currentAdmissions.get(x); if (isInDomain(admission.getProgramId().longValue(), providerManager.getProgramDomain(providerNo))) { request.setAttribute("isInProgramDomain", Boolean.TRUE); break; } } /* bed reservation view */ BedDemographic bedDemographic = bedDemographicManager .getBedDemographicByDemographic(Integer.valueOf(demographicNo), facilityId); request.setAttribute("bedDemographic", bedDemographic); RoomDemographic roomDemographic = getRoomDemographicManager() .getRoomDemographicByDemographic(Integer.valueOf(demographicNo), facilityId); if (roomDemographic != null) { Integer roomIdInt = roomDemographic.getId().getRoomId(); Room room = null; if (roomIdInt != null) { room = getRoomManager().getRoom(roomIdInt); } if (room != null) { roomDemographic.setRoom(room); } } request.setAttribute("roomDemographic", roomDemographic); if (tabBean.getTab().equals("Bed/Room Reservation")) { boolean isRefreshRoomDropDown = false; if (request.getAttribute("isRefreshRoomDropDown") != null && request.getAttribute("isRefreshRoomDropDown").equals("Y")) { isRefreshRoomDropDown = true; } else { isRefreshRoomDropDown = false; } String roomId = request.getParameter("roomId"); if (roomDemographic != null && roomId == null) { roomId = roomDemographic.getId().getRoomId().toString(); } // set bed program id Admission bedProgramAdmission = admissionManager .getCurrentBedProgramAdmission(Integer.valueOf(demographicNo)); Integer bedProgramId = null; if (bedProgramAdmission != null) { bedProgramId = (bedProgramAdmission != null) ? bedProgramAdmission.getProgramId() : null; } request.setAttribute("bedProgramId", bedProgramId); Bed reservedBed = null; if (bedDemographic == null) { bedDemographic = BedDemographic.create(Integer.valueOf(demographicNo), bedDemographicManager.getDefaultBedDemographicStatus(), providerNo); if (roomDemographic != null) { bedDemographic.setReservationStart(roomDemographic.getAssignStart()); bedDemographic.setReservationEnd(roomDemographic.getAssignEnd()); } reservedBed = null; } else { reservedBed = bedManager.getBed(bedDemographic.getBedId()); } if (isRefreshRoomDropDown) { bedDemographic.setRoomId(Integer.valueOf(roomId)); } clientForm.set("bedDemographic", bedDemographic); Room[] availableRooms = getRoomManager().getAvailableRooms(facilityId, bedProgramId, Boolean.TRUE, demographicNo); request.setAttribute("availableRooms", availableRooms); if ((isRefreshRoomDropDown && roomId != null) || (reservedBed == null && !"0".equals(roomId))) { request.setAttribute("roomId", roomId); } else if (reservedBed != null) { request.setAttribute("roomId", reservedBed.getRoomId().toString()); } else { request.setAttribute("roomId", "0"); } request.setAttribute("isAssignedBed", String.valueOf( getRoomManager().isAssignedBed((String) request.getAttribute("roomId"), availableRooms))); // retrieve an array of beds associated with this roomId Bed[] unreservedBeds = null; if (isRefreshRoomDropDown && request.getAttribute("unreservedBeds") != null) { unreservedBeds = (Bed[]) request.getAttribute("unreservedBeds"); } else if (reservedBed != null) { // unreservedBeds = bedManager.getBedsByRoomProgram(availableRooms, bedProgramId, false); unreservedBeds = bedManager.getCurrentPlusUnreservedBedsByRoom(reservedBed.getRoomId(), bedDemographic.getId().getBedId(), false); } clientForm.set("unreservedBeds", unreservedBeds); // set bed demographic statuses clientForm.set("bedDemographicStatuses", bedDemographicManager.getBedDemographicStatuses()); } /* forms */ if (tabBean.getTab().equals("Forms")) { request.setAttribute("regIntakes", genericIntakeManager.getRegIntakes(Integer.valueOf(demographicNo), facilityId)); request.setAttribute("quickIntakes", genericIntakeManager.getQuickIntakes(Integer.valueOf(demographicNo), facilityId)); // request.setAttribute("indepthIntakes", genericIntakeManager.getIndepthIntakes(Integer.valueOf(demographicNo), facilityId)); request.setAttribute("indepthIntakes", genericIntakeManager.getIntakesByType(Integer.valueOf(demographicNo), facilityId, 2)); request.setAttribute("generalIntakes", genericIntakeManager.getIntakesByType(Integer.valueOf(demographicNo), facilityId, 3)); request.setAttribute("programIntakes", genericIntakeManager.getProgramIntakes(Integer.valueOf(demographicNo), facilityId)); request.setAttribute("programsWithIntake", genericIntakeManager.getProgramsWithIntake(Integer.valueOf(demographicNo))); request.setAttribute("indepthIntakeNodes", genericIntakeManager.getIntakeNodesByType(2)); request.setAttribute("generalIntakeNodes", genericIntakeManager.getIntakeNodesByType(3)); /* survey module */ request.setAttribute("survey_list", surveyManager.getAllFormsForCurrentProviderAndCurrentFacility()); request.setAttribute("surveys", surveyManager.getFormsForCurrentProviderAndCurrentFacility(demographicNo)); /* consent forms */ int clientId = Integer.parseInt(demographicNo); List<IntegratorConsent> consentTemp = integratorConsentDao.findByFacilityAndDemographic(facilityId, clientId); TreeMap<Date, HashMap<String, Object>> consents = new TreeMap<Date, HashMap<String, Object>>( Collections.reverseOrder()); for (IntegratorConsent x : consentTemp) { HashMap<String, Object> map = new HashMap<String, Object>(); map.put("createdDate", DateFormatUtils.ISO_DATETIME_FORMAT.format(x.getCreatedDate()).replace('T', ' ')); Provider provider = providerDao.getProvider(x.getProviderNo()); map.put("provider", provider.getFormattedName()); map.put("consentId", x.getId()); consents.put(x.getCreatedDate(), map); } request.setAttribute("consents", consents.values()); // CDS forms List<CdsClientForm> cdsForms = cdsClientFormDao.findByFacilityClient(facilityId, clientId); request.setAttribute("cdsForms", cdsForms); // FULL OCAN Forms List<OcanStaffForm> ocanStaffForms = ocanStaffFormDao.findByFacilityClient(facilityId, clientId, "FULL"); request.setAttribute("ocanStaffForms", ocanStaffForms); // SELF+CORE OCAN Forms List<OcanStaffForm> selfOcanStaffForms = ocanStaffFormDao.findByFacilityClient(facilityId, clientId, "SELF"); request.setAttribute("selfOcanStaffForms", selfOcanStaffForms); // CORE OCAN Forms List<OcanStaffForm> coreOcanStaffForms = ocanStaffFormDao.findByFacilityClient(facilityId, clientId, "CORE"); request.setAttribute("coreOcanStaffForms", coreOcanStaffForms); } /* refer */ if (tabBean.getTab().equals("Refer")) { request.setAttribute("referrals", clientManager.getActiveReferrals(demographicNo, String.valueOf(facilityId))); if (loggedInInfo.currentFacility.isIntegratorEnabled()) { try { ArrayList<RemoteReferral> results = new ArrayList<RemoteReferral>(); // get local data List<RemoteReferral> remoteReferralsFromDB = remoteReferralDao .findByFacilityIdDemogprahicId(facilityId, demographicId); results.addAll(remoteReferralsFromDB); // get remote Data ReferralWs referralWs = CaisiIntegratorManager.getReferralWs(); Integer currentRemoteFacilityId = CaisiIntegratorManager.getCurrentRemoteFacility() .getIntegratorFacilityId(); List<Referral> referrals = referralWs.getLinkedReferrals(Integer.parseInt(demographicNo)); if (referrals != null) { for (Referral remoteReferral : referrals) { if (currentRemoteFacilityId.equals(remoteReferral.getSourceIntegratorFacilityId())) continue; RemoteReferral temp = new RemoteReferral(); CachedFacility cachedFacility = CaisiIntegratorManager .getRemoteFacility(remoteReferral.getDestinationIntegratorFacilityId()); temp.setReferredToFacilityName(cachedFacility.getName()); FacilityIdIntegerCompositePk pk = new FacilityIdIntegerCompositePk(); pk.setIntegratorFacilityId(remoteReferral.getDestinationIntegratorFacilityId()); pk.setCaisiItemId(remoteReferral.getDestinationCaisiProgramId()); CachedProgram cachedProgram = CaisiIntegratorManager.getRemoteProgram(pk); temp.setReferredToProgramName(cachedProgram.getName()); temp.setReferalDate(remoteReferral.getReferralDate()); Provider tempProvider = providerDao .getProvider(remoteReferral.getSourceCaisiProviderId()); temp.setReferringProviderNo(tempProvider.getFormattedName()); temp.setReasonForReferral(remoteReferral.getReasonForReferral()); temp.setPresentingProblem(remoteReferral.getPresentingProblem()); results.add(temp); } } Comparator<RemoteReferral> tempComparator = new Comparator<RemoteReferral>() { @Override public int compare(RemoteReferral o1, RemoteReferral o2) { if (o1.getReferalDate() == null && o2.getReferalDate() == null) return (0); if (o1.getReferalDate() == null) return (-1); if (o2.getReferalDate() == null) return (1); return (o1.getReferalDate().compareTo(o2.getReferalDate())); } }; Collections.sort(results, tempComparator); request.setAttribute("remoteReferrals", results); } catch (Exception e) { logger.error("Unexpected Error.", e); } } } /* service restrictions */ if (tabBean.getTab().equals("Service Restrictions")) { // request.setAttribute("serviceRestrictions", clientRestrictionManager.getActiveRestrictionsForClient(Integer.valueOf(demographicNo), new Date())); request.setAttribute("serviceRestrictions", clientRestrictionManager .getActiveRestrictionsForClient(Integer.valueOf(demographicNo), facilityId, new Date())); request.setAttribute("serviceRestrictionList", lookupManager.LoadCodeList("SRT", true, null, null)); } /* discharge */ if (tabBean.getTab().equals("Discharge")) { request.setAttribute("communityPrograms", programManager.getCommunityPrograms()); request.setAttribute("serviceAdmissions", admissionManager.getCurrentServiceProgramAdmission(Integer.valueOf(demographicNo))); request.setAttribute("temporaryAdmissions", admissionManager.getCurrentTemporaryProgramAdmission(Integer.valueOf(demographicNo))); request.setAttribute("current_bed_program", admissionManager.getCurrentBedProgramAdmission(Integer.valueOf(demographicNo))); request.setAttribute("current_community_program", admissionManager.getCurrentCommunityProgramAdmission(Integer.valueOf(demographicNo))); request.setAttribute("dischargeReasons", lookupManager.LoadCodeList("DRN", true, null, null)); request.setAttribute("dischargeReasons2", lookupManager.LoadCodeList("DR2", true, null, null)); } /* Relations */ DemographicRelationship demoRelation = new DemographicRelationship(); ArrayList<Hashtable<String, Object>> relList = demoRelation .getDemographicRelationshipsWithNamePhone(demographicNo, facilityId); List<JointAdmission> list = clientManager.getDependents(new Long(demographicNo)); JointAdmission clientsJadm = clientManager.getJointAdmission(new Long(demographicNo)); int familySize = list.size() + 1; if (familySize > 1) { request.setAttribute("groupHead", "yes"); } if (clientsJadm != null) { request.setAttribute("dependentOn", clientsJadm.getHeadClientId()); List<JointAdmission> depList = clientManager.getDependents(clientsJadm.getHeadClientId()); familySize = depList.size() + 1; Demographic headClientDemo = clientManager.getClientByDemographicNo("" + clientsJadm.getHeadClientId()); request.setAttribute("groupName", headClientDemo.getFormattedName() + " Group"); } if (relList != null && relList.size() > 0) { for (Hashtable h : relList) { String demographic = (String) h.get("demographicNo"); Long demoLong = new Long(demographic); JointAdmission demoJadm = clientManager.getJointAdmission(demoLong); // IS PERSON JOINTLY ADMITTED WITH ME, They will either have the same HeadClient or be my headClient if (clientsJadm != null && clientsJadm.getHeadClientId().longValue() == demoLong) { // they're my head client h.put("jointAdmission", "head"); } else if (demoJadm != null && clientsJadm != null && clientsJadm.getHeadClientId().longValue() == demoJadm.getHeadClientId().longValue()) { // They depend on the same person i do! h.put("jointAdmission", "dependent"); } else if (demoJadm != null && demoJadm.getHeadClientId().longValue() == new Long(demographicNo).longValue()) { // They depend on me h.put("jointAdmission", "dependent"); } // Can this person be added to my depended List if (clientsJadm == null && demoJadm == null && clientManager.getDependents(demoLong).size() == 0) { // yes if - i am not dependent on anyone // - this person is not dependent on someone // - this person is not a head of a family already h.put("dependentable", "yes"); } if (demoJadm != null) { // DEPENDS ON SOMEONE h.put("dependentOn", demoJadm.getHeadClientId()); if (demoJadm.getHeadClientId().longValue() == new Long(demographicNo).longValue()) { h.put("dependent", demoJadm.getTypeId()); } } else if (clientsJadm != null && clientsJadm.getHeadClientId().longValue() == demoLong) { // HEAD PERSON WON'T DEPEND ON ANYONE h.put("dependent", new Long(0)); } } request.setAttribute("relations", relList); request.setAttribute("relationSize", familySize); } }