List of usage examples for java.util Hashtable containsKey
public synchronized boolean containsKey(Object key)
From source file:io.github.msdk.features.ransacaligner.RansacAlignerMethod.java
private Hashtable<FeatureTableRow, FeatureTableRow> getAlignmentMap(FeatureTable featureTable) { // Create a table of mappings for best scores Hashtable<FeatureTableRow, FeatureTableRow> alignmentMapping = new Hashtable<FeatureTableRow, FeatureTableRow>(); // Create a sorted set of scores matching TreeSet<RowVsRowScore> scoreSet = new TreeSet<RowVsRowScore>(); // RANSAC algorithm List<AlignStructMol> list = ransacPeakLists(result, featureTable); PolynomialFunction function = this.getPolynomialFunction(list); List<FeatureTableRow> allRows = featureTable.getRows(); for (FeatureTableRow row : allRows) { // Calculate limits for a row with which the row can be aligned Range<Double> mzRange = mzTolerance.getToleranceRange(row.getMz()); double rt; try {// w w w . j ava2s . c om rt = function.value(row.getChromatographyInfo().getRetentionTime()); } catch (NullPointerException e) { rt = row.getChromatographyInfo().getRetentionTime(); } if (Double.isNaN(rt) || rt == -1) { rt = row.getChromatographyInfo().getRetentionTime(); } Range<Double> rtRange = rtToleranceAfterCorrection.getToleranceRange(rt); // Get all rows of the aligned feature table within the m/z and // RT limits List<FeatureTableRow> candidateRows = result.getRowsInsideRange(rtRange, mzRange); for (FeatureTableRow candidateRow : candidateRows) { RowVsRowScore score; if (requireSameCharge) { FeatureTableColumn<Integer> chargeColumn1 = featureTable.getColumn(ColumnName.CHARGE, null); FeatureTableColumn<Integer> chargeColumn2 = result.getColumn(ColumnName.CHARGE, null); Integer charge1 = row.getData(chargeColumn1); Integer charge2 = candidateRow.getData(chargeColumn2); if (!charge1.equals(charge2)) continue; } // Check ion annotation if (requireSameAnnotation) { FeatureTableColumn<List<IonAnnotation>> ionAnnotationColumn1 = featureTable .getColumn(ColumnName.IONANNOTATION, null); FeatureTableColumn<List<IonAnnotation>> ionAnnotationColumn2 = result .getColumn(ColumnName.IONANNOTATION, null); List<IonAnnotation> ionAnnotations1 = row.getData(ionAnnotationColumn1); List<IonAnnotation> ionAnnotations2 = candidateRow.getData(ionAnnotationColumn2); // Check that all ion annotations in first row are in // the candidate row boolean equalIons = false; if (ionAnnotations1 != null && ionAnnotations2 != null) { for (IonAnnotation ionAnnotation : ionAnnotations1) { for (IonAnnotation targetIonAnnotation : ionAnnotations2) { if (targetIonAnnotation.compareTo(ionAnnotation) == 0) equalIons = true; } } } if (!equalIons) continue; } try { double mzLength = mzRange.upperEndpoint() - mzRange.lowerEndpoint(); double rtLength = rtRange.upperEndpoint() - rtRange.lowerEndpoint(); score = new RowVsRowScore(row, candidateRow, mzLength, rtLength, new Float(rt)); scoreSet.add(score); } catch (Exception e) { return null; } } } // Iterate scores by descending order Iterator<RowVsRowScore> scoreIterator = scoreSet.iterator(); while (scoreIterator.hasNext()) { RowVsRowScore score = scoreIterator.next(); // Check if the row is already mapped if (alignmentMapping.containsKey(score.getFeatureTableRow())) { continue; } // Check if the aligned row is already filled if (alignmentMapping.containsValue(score.getAlignedRow())) { continue; } alignmentMapping.put(score.getFeatureTableRow(), score.getAlignedRow()); } return alignmentMapping; }
From source file:net.i2cat.csade.life2.backoffice.bl.StatisticsManager.java
public JSONObject getListRegionsJSON(JQueryDataTableParamModel param, String supraregion, String country, boolean showAll) throws RemoteException, ServiceException { JSONObject jsonResponse = new JSONObject(); Regions[] result = null;/*from www . ja v a2 s . com*/ String filter = ""; Hashtable<String, String> countries = new Hashtable<String, String>(); countries.put("AT", "Austria"); countries.put("BEL", "Belgium"); countries.put("BGR", "Bulgaria"); countries.put("CYP", "Cyprus"); countries.put("CZE", "Czech Republic"); countries.put("DNK", "Denmark"); countries.put("EST", "Estonia"); countries.put("FIN", "Finland"); countries.put("FRA", "France"); countries.put("DEU", "Germany"); countries.put("GBR", "Great Britain"); countries.put("GRC", "Greece"); countries.put("HUN", "Hungary"); countries.put("IRL", "Ireland"); countries.put("ITA", "Italy"); countries.put("LVA", "Latvia"); countries.put("LTU", "Lithuania"); countries.put("LUX", "Luxembourg"); countries.put("MLT", "Malta"); countries.put("NLD", "Netherlands"); countries.put("POL", "Poland"); countries.put("PRT", "Portugal"); countries.put("ROU", "Romania"); countries.put("SVK", "Slovakia"); countries.put("SVN", "Slovenia"); countries.put("ESP", "Spain"); countries.put("SWE", "Sweden"); if (param == null) throw new ServiceException("Invalid Session!"); if (param.sSearch != null && !"".equals(param.sSearch)) { filter = "name like '%" + param.sSearch + "%' "; } if (supraregion != null && !"".equals(supraregion)) { filter = "supraRegion like '%" + supraregion + "%'"; } if (country != null && !"".equals(country)) { filter = "country_code like '%" + country + "%'"; } int total = 0; String login = ""; if (!showAll) login = param.login; if (filter == null || "".equals(filter.trim())) total = sd.countRegions(login); else total = sd.countRegions(login, filter); result = sd.listRegions(filter, param.iDisplayStart, param.iDisplayLength, login); if (result != null) { try { jsonResponse.put("iTotalRecords", total); //El total despues de filtrar jsonResponse.put("iTotalDisplayRecords", total); JSONArray data = new JSONArray(); for (Regions c : result) { JSONArray row = new JSONArray(); row.add("<a href=\"#\" onclick=\"showFormRegion('" + c.getId() + "');\">" + c.getId() + "</a>"); row.add(StringEscapeUtils.escapeHtml(c.getName())); //StringEscapeUtils.escapeHtml( row.add(StringEscapeUtils.escapeHtml(c.getSupraRegion())); row.add(StringEscapeUtils .escapeHtml(countries.containsKey(c.getCountry()) ? countries.get(c.getCountry()) : c.getCountry())); row.add("" + c.getRadius()); data.add(row); } jsonResponse.put("sEcho", param.sEcho); jsonResponse.put("aaData", data); } catch (JSONException e) { } } else { jsonResponse.put("aaData", "[]"); } return jsonResponse; }
From source file:ffx.potential.parsers.XYZFilter.java
/** * {@inheritDoc}/*from ww w .j av a2 s . c o m*/ * * Parse the XYZ File */ @Override public boolean readFile() { File xyzFile = activeMolecularAssembly.getFile(); if (forceField == null) { logger.warning(" No force field is associated with " + xyzFile.toString()); return false; } try { FileReader fr = new FileReader(xyzFile); BufferedReader br = new BufferedReader(fr); String data = br.readLine(); // Read blank lines at the top of the file while (data != null && data.trim().equals("")) { data = br.readLine(); } if (data == null) { return false; } String tokens[] = data.trim().split(" +", 2); int numberOfAtoms = Integer.parseInt(tokens[0]); if (numberOfAtoms < 1) { return false; } if (tokens.length == 2) { getActiveMolecularSystem().setName(tokens[1]); } logger.info("\n Opening " + xyzFile.getName() + " with " + numberOfAtoms + " atoms\n"); // The header line is reasonable - prepare to parse atom lines. Hashtable<Integer, Integer> labelHash = new Hashtable<Integer, Integer>(); int label[] = new int[numberOfAtoms]; int bonds[][] = new int[numberOfAtoms][8]; double d[][] = new double[numberOfAtoms][3]; boolean renumber = false; atomList = new ArrayList<Atom>(); // Loop over the expected number of atoms. for (int i = 0; i < numberOfAtoms; i++) { if (!br.ready()) { return false; } data = br.readLine(); if (data == null) { logger.warning("Check atom " + (i + 1) + " in " + activeMolecularAssembly.getFile().getName()); return false; } tokens = data.trim().split(" +"); if (tokens == null || tokens.length < 6) { logger.warning("Check atom " + (i + 1) + " in " + activeMolecularAssembly.getFile().getName()); return false; } // Valid number of tokens, so try to parse this line. label[i] = Integer.parseInt(tokens[0]); // Check for valid atom numbering, or flag for re-numbering. if (label[i] != i + 1) { renumber = true; } String atomName = tokens[1]; d[i][0] = Double.parseDouble(tokens[2]); d[i][1] = Double.parseDouble(tokens[3]); d[i][2] = Double.parseDouble(tokens[4]); int type = Integer.parseInt(tokens[5]); AtomType atomType = forceField.getAtomType(Integer.toString(type)); if (atomType == null) { StringBuilder message = new StringBuilder("Check atom type "); message.append(type).append(" for Atom ").append(i + 1); message.append(" in ").append(activeMolecularAssembly.getFile().getName()); logger.warning(message.toString()); return false; } Atom a = new Atom(i + 1, atomName, atomType, d[i]); atomList.add(a); // Bond Data int numberOfBonds = tokens.length - 6; for (int b = 0; b < 8; b++) { if (b < numberOfBonds) { int bond = Integer.parseInt(tokens[6 + b]); bonds[i][b] = bond; } else { bonds[i][b] = 0; } } } // Check if this is an archive. if (br.ready()) { // Read past blank lines between archive files data = br.readLine().trim(); while (data != null && data.equals("")) { data = br.readLine().trim(); } if (data != null) { tokens = data.split(" +", 2); if (tokens != null && tokens.length > 0) { try { int archiveNumberOfAtoms = Integer.parseInt(tokens[0]); if (archiveNumberOfAtoms == numberOfAtoms) { setType(FileType.ARC); } } catch (Exception e) { tokens = null; } } } } br.close(); fr.close(); // Try to renumber if (renumber) { for (int i = 0; i < numberOfAtoms; i++) { if (labelHash.containsKey(label[i])) { logger.warning("Two atoms have the same index: " + label[i]); return false; } labelHash.put(label[i], i + 1); } for (int i = 0; i < numberOfAtoms; i++) { int j = -1; while (j < 3 && bonds[i][++j] > 0) { bonds[i][j] = labelHash.get(bonds[i][j]); } } } bondList = new ArrayList<Bond>(); int c[] = new int[2]; for (int i = 1; i <= numberOfAtoms; i++) { int a1 = i; int j = -1; while (j < 7 && bonds[i - 1][++j] > 0) { int a2 = bonds[i - 1][j]; if (a1 < a2) { if (a1 > numberOfAtoms || a1 < 1 || a2 > numberOfAtoms || a2 < 1) { logger.warning("Check the Bond Bewteen " + a1 + " and " + a2 + " in " + activeMolecularAssembly.getFile().getName()); return false; } // Check for bidirectional connection boolean bidirectional = false; int k = -1; while (k < 7 && bonds[a2 - 1][++k] > 0) { int a3 = bonds[a2 - 1][k]; if (a3 == a1) { bidirectional = true; break; } } if (!bidirectional) { logger.warning("Check the Bond Bewteen " + a1 + " and " + a2 + " in " + activeMolecularAssembly.getFile().getName()); return false; } Atom atom1 = atomList.get(a1 - 1); Atom atom2 = atomList.get(a2 - 1); if (atom1 == null || atom2 == null) { logger.warning("Check the Bond Bewteen " + a1 + " and " + a2 + " in " + activeMolecularAssembly.getFile().getName()); return false; } Bond bond = new Bond(atom1, atom2); c[0] = atom1.getAtomType().atomClass; c[1] = atom2.getAtomType().atomClass; String key = BondType.sortKey(c); BondType bondType = forceField.getBondType(key); if (bondType == null) { logger.severe("No BondType for key: " + key); } else { bond.setBondType(bondType); } bondList.add(bond); } } } /* if (getType() == FileType.ARC) { return readtrajectory(); } */ return true; } catch (IOException e) { logger.severe(e.toString()); } return false; }
From source file:org.talend.designer.core.ui.editor.process.Process.java
/** * DOC qzhang Comment method "loadNode". * /*from w w w . j av a2 s . c o m*/ * @param nType * @param component * @return */ protected Node loadNode(NodeType nType, IComponent component, Hashtable<String, Node> nodesHashtable, EList listParamType, boolean isJunitContainer) { Node nc; nc = new Node(component, this); nc.setLocation(new Point(nType.getPosX(), nType.getPosY())); Point offset = new Point(nType.getOffsetLabelX(), nType.getOffsetLabelY()); nc.getNodeLabel().setOffset(offset); if (nType.isSetSizeX()) { nc.setSize(new Dimension(nType.getSizeX(), nType.getSizeY())); } loadElementParameters(nc, listParamType); if (nodesHashtable.containsKey(nc.getUniqueName())) { // if the uniquename is already in the list, there must be a problem with the job. // simply don't load the component return null; } // update the value of process type IElementParameter processParam = nc.getElementParameterFromField(EParameterFieldType.PROCESS_TYPE); if (processParam != null) { IElementParameter processIdParam = processParam.getChildParameters() .get(EParameterName.PROCESS_TYPE_PROCESS.getName()); IElementParameter processVersionParam = processParam.getChildParameters() .get(EParameterName.PROCESS_TYPE_VERSION.getName()); ProcessItem processItem = null; if (processVersionParam != null) { processItem = ItemCacheManager.getProcessItem((String) processIdParam.getValue(), (String) processVersionParam.getValue()); } else { processItem = ItemCacheManager.getProcessItem((String) processIdParam.getValue()); } if (processItem != null) { nc.setPropertyValue(processParam.getName(), processItem.getProperty().getLabel()); } } // nc.setData(nType.getBinaryData(), nType.getStringData()); if (nc.getExternalNode() != null && nType.getNodeData() != null) { nc.getExternalNode().buildExternalData(EcoreUtil.copy(nType.getNodeData())); nc.setExternalData(nc.getExternalNode().getExternalData()); nc.getExternalNode().setOriginalNode(nc); } loadSchema(nc, nType); // add a reject connector if the node has validation rule. ValidationRulesUtil.createRejectConnector(nc); loadColumnsBasedOnSchema(nc, listParamType); NodeContainer nodeContainer = null;// loadNodeContainer(nc, nType); if (isJunitContainer) { if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerGEFService.class)) { ITestContainerGEFService testContainerService = (ITestContainerGEFService) GlobalServiceRegister .getDefault().getService(ITestContainerGEFService.class); if (testContainerService != null) { nodeContainer = testContainerService.createJunitContainer(nc); } } } else if (nc.isJoblet()) { nodeContainer = new JobletContainer(nc); } else if (nc.isMapReduce()) { nodeContainer = new JobletContainer(nc); } else { nodeContainer = new NodeContainer(nc); } addNodeContainer(nodeContainer); nodesHashtable.put(nc.getUniqueName(), nc); updateAllMappingTypes(); nc.setNeedLoadLib(false); if (nc.isJoblet()) { IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault() .getService(IJobletProviderService.class); if (service != null) { service.reloadJobletProcess(nc); } } return nc; }
From source file:org.unitime.timetable.solver.TimetableDatabaseLoader.java
private void loadCommittedStudentConflicts(org.hibernate.Session hibSession, Set<Long> offeringsToAvoid) { //Load all committed assignment - student relations that may be relevant List<Object[]> assignmentEnrollments = (List<Object[]>) hibSession .createQuery("select distinct a, e.studentId, io.uniqueId from " + "Solution s inner join s.assignments a inner join s.studentEnrollments e inner join a.clazz.schedulingSubpart.instrOfferingConfig.instructionalOffering io " + "where " + "s.commited=true and s.owner.session.uniqueId=:sessionId and s.owner not in (" + iSolverGroupIds + ") and " + "a.clazz=e.clazz") .setLong("sessionId", iSessionId.longValue()).list(); // Filter out relevant relations (relations that are for loaded students) Hashtable<Assignment, Set<Student>> assignments = new Hashtable<Assignment, Set<Student>>(); for (Object[] result : assignmentEnrollments) { Assignment assignment = (Assignment) result[0]; Long studentId = (Long) result[1]; Long offeringId = (Long) result[2]; if (offeringsToAvoid.contains(offeringId)) continue; Student student = (Student) iStudents.get(studentId); if (student != null) { Set<Student> students = assignments.get(assignment); if (students == null) { students = new HashSet<Student>(); assignments.put(assignment, students); }// w ww. ja v a2 s. c o m students.add(student); } } // Ensure no assignment-class relation is got from the cache for (Iterator i1 = assignmentEnrollments.iterator(); i1.hasNext();) { Object[] result = (Object[]) i1.next(); Assignment assignment = (Assignment) result[0]; if (!assignments.containsKey(assignment)) hibSession.evict(assignment); } // Make up the appropriate committed placements and propagate those through the course structure iProgress.setPhase("Loading student conflicts with commited solutions ...", assignments.size()); for (Iterator i1 = assignments.entrySet().iterator(); i1.hasNext();) { Map.Entry entry = (Map.Entry) i1.next(); Assignment assignment = (Assignment) entry.getKey(); HashSet students = (HashSet) entry.getValue(); Placement committedPlacement = assignment.getPlacement(); for (Iterator i2 = students.iterator(); i2.hasNext();) { Student student = (Student) i2.next(); student.addCommitedPlacement(committedPlacement); } if (!iLectures.containsKey(assignment.getClassId())) { iLectures.put(assignment.getClassId(), committedPlacement.variable()); getModel().addVariable(committedPlacement.variable()); } propagateCommittedAssignment(students, assignment); iProgress.incProgress(); } }
From source file:com.afunms.system.manage.equipManager.java
/** * HONGLI bid// www. jav a 2s . co m * * @param vo * @param deviceHash * @return */ private Hashtable getTreeBidHash(User vo, Hashtable deviceHash) { Hashtable treeBidHash = new Hashtable(); String bids = vo.getBusinessids(); String[] bidsArr = bids.split(","); // id String treeBidRouter = ""; String treeBidHost = ""; String treeBidSwitch = ""; String treeBidDb = ""; String treeBidMid = ""; String treeBidService = ""; String treeBidSecu = ""; boolean loopRoute = true; boolean loopHost = true; boolean loopSwitch = true; boolean loopDb = true; boolean loopMid = true; boolean loopService = true; boolean loopSecu = true; // treeBid List routelist = null; List hostlist = null; List switchlist = null; List dblist = null; List seculist = null; // List iislist = (ArrayList) session.getAttribute("iislist"); List tomcatlist = (ArrayList) session.getAttribute("tomcatlist"); List weblogiclist = (ArrayList) session.getAttribute("weblogiclist"); List waslist = (ArrayList) session.getAttribute("waslist"); List dominolist = (ArrayList) session.getAttribute("dominolist"); List mqlist = (ArrayList) session.getAttribute("mqlist"); List jbosslist = (ArrayList) session.getAttribute("jbosslist"); List apachelist = (ArrayList) session.getAttribute("apachelist"); // List socketlist = (ArrayList) session.getAttribute("socketlist"); List ftplist = (ArrayList) session.getAttribute("ftplist"); List emaillist = (ArrayList) session.getAttribute("emaillist"); List weblist = (ArrayList) session.getAttribute("weblist"); if (deviceHash.containsKey("routelist")) { routelist = (ArrayList) deviceHash.get("routelist"); } if (deviceHash.containsKey("hostlist")) { hostlist = (ArrayList) deviceHash.get("hostlist"); } if (deviceHash.containsKey("switchlist")) { switchlist = (ArrayList) deviceHash.get("switchlist"); } if (deviceHash.containsKey("dblist")) { dblist = (List) deviceHash.get("dblist"); } if (deviceHash.containsKey("seculist")) { seculist = (ArrayList) deviceHash.get("seculist"); } for (int i = 0; i < bidsArr.length; i++) { if (bidsArr[i] != null && !bidsArr[i].equals("")) { // if (routelist != null && loopRoute) { for (int j = 0; j < routelist.size(); j++) { HostNode node = (HostNode) routelist.get(j); if (node != null && node.getBid() != null && !node.getBid().contains(bidsArr[i])) { // continue; } else { // treeBidRouter = bidsArr[i]; loopRoute = false; break; } } } // if (hostlist != null && loopHost) { for (int j = 0; j < hostlist.size(); j++) { HostNode node = (HostNode) hostlist.get(j); if (node != null && node.getBid() != null && !node.getBid().contains(bidsArr[i])) { // continue; } else { // treeBidHost = bidsArr[i]; loopHost = false; break; } } } // if (switchlist != null && loopSwitch) { for (int j = 0; j < switchlist.size(); j++) { HostNode node = (HostNode) switchlist.get(j); if (node != null && node.getBid() != null && !node.getBid().contains(bidsArr[i])) { // continue; } else { // treeBidSwitch = bidsArr[i]; loopSwitch = false; break; } } } // if (dblist != null && loopDb) { for (int j = 0; j < dblist.size(); j++) { DBVo node = (DBVo) dblist.get(j); if (node != null && node.getBid() != null && !node.getBid().contains(bidsArr[i])) { // continue; } else { // treeBidDb = bidsArr[i]; loopDb = false; break; } } } // if (loopMid) { if (iislist != null && loopMid) { for (int j = 0; j < iislist.size(); j++) { IISConfig node = (IISConfig) iislist.get(j); if (node != null && node.getNetid() != null && !node.getNetid().contains(bidsArr[i])) { // continue; } else { // treeBidMid = bidsArr[i]; loopMid = false; break; } } } if (tomcatlist != null && loopMid) { for (int j = 0; j < tomcatlist.size(); j++) { Tomcat node = (Tomcat) tomcatlist.get(j); // System.out.println("-------"+node.getBid()); if (node != null && node.getBid() != null && !node.getBid().contains(bidsArr[i])) { // continue; } else { // treeBidMid = bidsArr[i]; loopDb = false; break; } } } if (weblogiclist != null && loopMid) { for (int j = 0; j < weblogiclist.size(); j++) { WeblogicConfig node = (WeblogicConfig) weblogiclist.get(j); if (node != null && node.getNetid() != null && !node.getNetid().contains(bidsArr[i])) { // continue; } else { // treeBidMid = bidsArr[i]; loopDb = false; break; } } } if (waslist != null && loopMid) { for (int j = 0; j < waslist.size(); j++) { WasConfig node = (WasConfig) waslist.get(j); if (node != null && node.getNetid() != null && !node.getNetid().contains(bidsArr[i])) { // continue; } else { // treeBidMid = bidsArr[i]; loopDb = false; break; } } } if (dominolist != null && loopMid) { for (int j = 0; j < dominolist.size(); j++) { DominoConfig node = (DominoConfig) dominolist.get(j); if (node != null && node.getNetid() != null && !node.getNetid().contains(bidsArr[i])) { // continue; } else { // treeBidMid = bidsArr[i]; loopDb = false; break; } } } if (mqlist != null && loopMid) { for (int j = 0; j < mqlist.size(); j++) { MQConfig node = (MQConfig) mqlist.get(j); if (node != null && node.getNetid() != null && !node.getNetid().contains(bidsArr[i])) { // continue; } else { // treeBidMid = bidsArr[i]; loopDb = false; break; } } } if (jbosslist != null && loopMid) { for (int j = 0; j < jbosslist.size(); j++) { JBossConfig node = (JBossConfig) jbosslist.get(j); if (node != null && node.getNetid() != null && !node.getNetid().contains(bidsArr[i])) { // continue; } else { // treeBidMid = bidsArr[i]; loopDb = false; break; } } } if (apachelist != null && loopMid) { for (int j = 0; j < apachelist.size(); j++) { ApacheConfig node = (ApacheConfig) apachelist.get(j); if (node != null && node.getNetid() != null && !node.getNetid().contains(bidsArr[i])) { // continue; } else { // treeBidMid = bidsArr[i]; loopDb = false; break; } } } } // if (loopService) { if (socketlist != null && loopService) { for (int j = 0; j < socketlist.size(); j++) { PSTypeVo node = (PSTypeVo) socketlist.get(j); if (node != null && node.getBid() != null && !node.getBid().contains(bidsArr[i])) { // continue; } else { // treeBidService = bidsArr[i]; loopService = false; break; } } } if (ftplist != null && loopService) { for (int j = 0; j < ftplist.size(); j++) { FTPConfig node = (FTPConfig) ftplist.get(j); if (node != null && node.getBid() != null && !node.getBid().contains(bidsArr[i])) { // FTP continue; } else { // treeBidService = bidsArr[i]; loopService = false; break; } } } if (emaillist != null && loopService) { for (int j = 0; j < emaillist.size(); j++) { EmailMonitorConfig node = (EmailMonitorConfig) emaillist.get(j); if (node != null && node.getBid() != null && !node.getBid().contains(bidsArr[i])) { // continue; } else { // treeBidService = bidsArr[i]; loopService = false; break; } } } if (weblist != null && loopService) { for (int j = 0; j < weblist.size(); j++) { WebConfig node = (WebConfig) weblist.get(j); if (node != null && node.getNetid() != null && !node.getNetid().contains(bidsArr[i])) { // continue; } else { // treeBidService = bidsArr[i]; loopService = false; break; } } } } // if (seculist != null && loopSecu) { for (int j = 0; j < seculist.size(); j++) { HostNode node = (HostNode) seculist.get(j); if (node != null && node.getBid() != null && !node.getBid().contains(bidsArr[i])) { // continue; } else { // treeBidSecu = bidsArr[i]; loopSecu = false; break; } } } } } treeBidHash.put("treeBidRouter", treeBidRouter); treeBidHash.put("treeBidHost", treeBidHost); treeBidHash.put("treeBidSwitch", treeBidSwitch); treeBidHash.put("treeBidDb", treeBidDb); treeBidHash.put("treeBidMid", treeBidMid); treeBidHash.put("treeBidService", treeBidService); treeBidHash.put("treeBidSecu", treeBidSecu); return treeBidHash; }
From source file:us.mn.state.health.lims.testanalyte.daoimpl.TestAnalyteTestResultDAOImpl.java
public void updateData(Test test, List allOldTestAnalytes, List allOldTestResults, List allNewTestAnalytes, List allNewTestResults) throws LIMSRuntimeException { Transaction tx = null;/* w ww .j a v a2s. co m*/ Session session = null; try { session = HibernateUtil.getSession(); tx = session.beginTransaction(); // this stores all testResult Ids (test results can be shared // amongst components) Hashtable allOldTestResultsForTest = new Hashtable(); Hashtable allNewTestResultsForTest = new Hashtable(); // load hashtables if (allNewTestResults != null) { for (int j = 0; j < allNewTestResults.size(); j++) { TestResult tr = (TestResult) allNewTestResults.get(j); if (!StringUtil.isNullorNill(tr.getId())) { allNewTestResultsForTest.put(tr.getId(), tr); } } } if ((allOldTestResults != null) && (allOldTestResults.size() > 0)) { for (int j = 0; j < allOldTestResults.size(); j++) { TestResult tr = (TestResult) allOldTestResults.get(j); allOldTestResultsForTest.put(tr.getId(), tr); } } // Get a List of allNewTrIds (all new test result Ids) from // Hashtable allNewTestResultsForTest // Note : this does not include new ones that don't have an id yet!! Set allNewTrIdsSet = (Set) allNewTestResultsForTest.keySet(); Iterator allNewTrIdsIt = allNewTrIdsSet.iterator(); List allNewTrIds = new ArrayList(); while (allNewTrIdsIt.hasNext()) { allNewTrIds.add(allNewTrIdsIt.next()); } // Get a List of allOldTrIds (all old test result Ids) from // Hashtable allOldTestResultsForTest Set allOldTrIdsSet = (Set) allOldTestResultsForTest.keySet(); Iterator allOldTrIdsIt = allOldTrIdsSet.iterator(); List allOldTrIds = new ArrayList(); while (allOldTrIdsIt.hasNext()) { allOldTrIds.add(allOldTrIdsIt.next()); } // Loop through all new test analytes for (int i = 0; i < allNewTestAnalytes.size(); i++) { TestAnalyte testAnalyte = (TestAnalyte) allNewTestAnalytes.get(i); List testResults = new ArrayList(); List oldTestResults = new ArrayList(); TestAnalyte testAnalyteClone; //bug#1342 String analyteType; if (!StringUtil.isNullorNill(testAnalyte.getId())) { // UPDATE testAnalyteClone = readTestAnalyte(testAnalyte.getId()); oldTestResults = testAnalyteClone.getTestResults(); //bug#1342 recover old test analyte type (R/N) as this is not submitted //correctly when select is disabled and User re-sorts analyteType = testAnalyteClone.getTestAnalyteType(); PropertyUtils.copyProperties(testAnalyteClone, testAnalyte); //bug#1342 recover old test analyte type (R/N) as this is not submitted //correctly when select is disabled and User resorts if (testAnalyte.getTestAnalyteType() == null) { testAnalyteClone.setTestAnalyteType(analyteType); } // list of testResults testResults = testAnalyteClone.getTestResults(); session.merge(testAnalyteClone); session.flush(); session.clear(); } else { // INSERT testAnalyte.setId(null); // list of testResults testResults = testAnalyte.getTestResults(); session.save(testAnalyte); session.flush(); session.clear(); } List newIds = new ArrayList(); List oldIds = new ArrayList(); if (testResults != null) { for (int j = 0; j < testResults.size(); j++) { TestResult tr = (TestResult) testResults.get(j); newIds.add(tr.getId()); } } if ((oldTestResults != null) && (oldTestResults.size() > 0)) { List listOfOldOnesToRemove = new ArrayList(); for (int j = 0; j < oldTestResults.size(); j++) { TestResult tr = (TestResult) oldTestResults.get(j); oldIds.add(tr.getId()); if (!newIds.contains(tr.getId())) { // remove ones that are to be deleted listOfOldOnesToRemove.add(new Integer(j)); } } int decreaseOTRIndexBy = 0; int decreaseOIIndexBy = 0; for (int j = 0; j < listOfOldOnesToRemove.size(); j++) { oldTestResults .remove(((Integer) listOfOldOnesToRemove.get(j)).intValue() - decreaseOTRIndexBy++); oldIds.remove(((Integer) listOfOldOnesToRemove.get(j)).intValue() - decreaseOIIndexBy++); } } //Loop through new testResults for this particular testAnalyte if (testResults != null) { for (int j = 0; j < testResults.size(); j++) { TestResult teRe = (TestResult) testResults.get(j); int index = oldIds.indexOf(teRe.getId()); if (!StringUtil.isNullorNill(teRe.getId()) && allOldTestResultsForTest.containsKey(teRe.getId())) { //UPDATE TestResult testResultClone = readTestResult(teRe.getId()); PropertyUtils.copyProperties(testResultClone, teRe); if (index >= 0) { oldTestResults.set(index, testResultClone); } else { oldTestResults.add(testResultClone); } session.merge(teRe); session.flush(); session.clear(); } else { //INSERT oldTestResults.add(teRe); session.save(teRe); session.flush(); session.clear(); } } } // remove test analytes from total list which holds all test analytes to be deleted (this is not a // candidate for delete because it is amongst the new test // analytes list!) if (allOldTestAnalytes != null) { for (int x = 0; x < allOldTestAnalytes.size(); x++) { TestAnalyte ta = (TestAnalyte) allOldTestAnalytes.get(x); if (ta.getId().equals(testAnalyte.getId())) { allOldTestAnalytes.remove(x); break; } } } } // BEGIN OF DELETE // Delete any left-over old test analytes if ((allOldTestAnalytes != null) && (allOldTestAnalytes.size() > 0)) { for (int i = 0; i < allOldTestAnalytes.size(); i++) { TestAnalyte testAnalyte = (TestAnalyte) allOldTestAnalytes.get(i); session.delete(testAnalyte); session.flush(); session.clear(); } } // Delete any left-over old test results if ((allOldTrIds != null) && (allOldTrIds.size() > 0)) { for (int i = 0; i < allOldTrIds.size(); i++) { if (!allNewTrIds.contains(allOldTrIds.get(i))) { TestResult testResult = (TestResult) allOldTestResultsForTest.get(allOldTrIds.get(i)); session.delete(testResult); session.flush(); session.clear(); } } } // END OF DELETE tx.commit(); } catch (Exception e) { //bugzilla 2154 LogEvent.logError("TestAnalyteTestResultDAOImpl", "updateData()", e.toString()); if (tx != null) tx.rollback(); throw new LIMSRuntimeException("Error in TestAnalyteTestResult updateData()", e); } }
From source file:at.tuwien.ifs.somtoolbox.reportgenerator.output.SOMDescriptionLATEX.java
/** * Creates output describing the layout of the created som this includes tables showing the distribution of the * input vectors of the som, as well as (if available) the distribution of the classes on the som. In addition, if * the user selected input items for getting their position on the trained SOM, this information is also created in * this function.//from www. jav a2s.c om * * @param classInfoAvailable true if class information are available (and therefore a piechart should be inserted, * false otherwise) */ protected void printMapLayout(boolean classInfoAvailable) { // the information about the selected data items - listed InputDatum input; Unit unit; String key; Hashtable<String, Vector<InputDatum>> lookup = new Hashtable<String, Vector<InputDatum>>(); // there we store // for each unit the // input vectors // mapped to it Vector<InputDatum> mappedInputs; // --- the first table with number of input items and class distribution String clsinf = ""; if (classInfoAvailable) { clsinf = " and class distribution"; } this.writer.appendLatexOutput("\\paragraph{Distribution of the input vectors" + clsinf + ":}\n"); this.writer.appendLatexOutput("Table 3 on page \\pageref{tab:pie} is the Visualisation of a Hit Histogram." + "It shows the amount of input units mapped to their corresponding units on the SOM."); if (classInfoAvailable) { this.writer.appendLatexOutput( " The Class Pie Chart Image gives an Overview on the amount of classes being mappewd to this unit." + "White gaps signify empty spaces on the Map, therefore can be interpretetd as natural cluster boundaries.\\\\"); } this.printDistributionDetailTable(null, classInfoAvailable); this.writer.appendOutput("A more sophisticated way to visualize the distributioun of classes is the SDH. " + TextualDescriptionProvider.getScientificDescription("sdh") + "Fgure 1,2 \\& 3 on page \\pageref{fig:sdh1} are the Visualisations SDH Images with increasing Values of \\textit{k}\n"); int runID = this.testrun.getRunId(); this.testrun.createSDHImages(this.imgDir + System.getProperty("file.separator"), "SDH_Visualization.jpg", 30, true, -1); this.testrun.createSDHImages(this.imgDir + System.getProperty("file.separator"), "SDH_Visualization.jpg", 30, true, -1); this.testrun.createSDHImages(this.imgDir + System.getProperty("file.separator"), "SDH_Visualization.jpg", 30, true, -1); this.writer.appendOutput("\\begin{center}\n" + "\\begin{figure}[htbp]\n"); int dim = this.testrun.getSOMDimensions(); for (int i = 1; i < dim; i = i + dim / 3) { this.writer.appendOutput("\\begin{minipage}[hbt]{4.5cm}\n" + "\\includegraphics[width=4.5cm]{" + SOMDescriptionLATEX.imgSubdir + "/" + "SDH_pics_" + this.testrun.getRunId() + "/" + "s" + i + "_" + this.testrun.getRunId() + "_SDH_Visualization.jpg}"); this.writer.appendOutput("\\caption{SDH with k = " + i + "}" + "\\label{fig:sdh" + i + "}" + "\\end{minipage}\n" + "\\hspace{2cm}\n"); } this.writer.appendOutput("\\end{figure}\n" + "\\end{center}"); // --- then we give some information about the selected input vectors if (this.dataset.getNumberOfSelectedInputs() > 0) { this.writer .appendLatexOutput("\\subsection{Location and quantization errors of selected input items:}\n"); this.writer.appendOutput( "Table 4 on page \\pageref{tab:loc} shows for all input items their corresponding Map Node and the Quantization Error \\textit{e}m$^q$ of that Node. Additionally the Distance " + "$\\xi_p^s$ from the Input units Vector \\textit{s} to the prototype vector \\textit{p} of the SOM unit." + "is mapped, and how big the quantization error is. After that, this is visualized in another table.\\\\\n"); // first a list of the selected data items with more information about them: this.writer.appendOutput("\\begin{longtable}{|c|c|l|l|l|}\\hline\n" + "Item No. \n&" + "Mapped Node \n&" + "\\textit{e}$^q$ &\n" + "$\\xi_p^s$\n" + "\\\\"); // we have to somehow map the data items to the units, s.t. we than can walk through the // units to retrieve the corresponding data items // while doing this, we print a list of all selected items with some additional information for (int i = 0; i < this.dataset.getNumberOfSelectedInputs(); i++) { this.writer.appendLatexOutput("\\hline"); input = this.dataset.getInputDatum(this.dataset.getSelectedInputId(i)); unit = this.testrun.getUnitMappedTo(input); key = unit.getXPos() + "_" + unit.getYPos(); // create the latex output for the list this.writer.appendLatexOutput(input.getLabel() + "&" // where + "[" + unit.getXPos() + ", " + unit.getYPos() + "] " + " & (qe=" + String.format("%.5f", this.testrun.getQEForUnit(unit.getXPos(), unit.getYPos())) + "" + " and mqe=" + String.format("%.5f", this.testrun.getMQEForUnit(unit.getXPos(), unit.getYPos())) + ")&" // qe + String.format("%.5f", this.testrun.getInputMappedQE(input.getLabel()).getQE()) + "\n"); this.writer.appendLatexOutput("\\\\"); // add this input to the lookup table for creating the table if (lookup.containsKey(key)) { // there's already one input vector mapped to this unit mappedInputs = lookup.get(key); lookup.remove(key); } else { // new mappedInputs = new Vector<InputDatum>(); } mappedInputs.add(input); lookup.put(key, mappedInputs); } this.writer.appendLatexOutput( "\\hline\\caption{Location and Quantization errors of selected input items}\n" + "\\label{tab:loc}\n" + "\\end{longtable}\n"); // print the table with the datasets inserted // NO!! PAPER IS TOO SMALL FOR IT :( // this.writer.appendLatexOutput("The following table visualized the information given in the list above. Values enclosed by \"\" denote " // + // "the label of a selected input item, the number in the top left corner of each cell gives the number of // input items totally mapped to // this unit. "); // this.printDistributionDetailTable(lookup, classInfoAvailable); } }
From source file:com.afunms.system.manage.UserManager.java
/** * HONGLI bid//from w w w .ja v a2s. c o m * * @param vo * @param deviceHash * @return */ private Hashtable getTreeBidHash(User vo, Hashtable deviceHash) { Hashtable treeBidHash = new Hashtable(); String bids = vo.getBusinessids(); String[] bidsArr = bids.split(","); // id String treeBidRouter = ""; String treeBidHost = ""; String treeBidSwitch = ""; String treeBidDb = ""; String treeBidMid = ""; String treeBidService = ""; String treeBidSecu = ""; boolean loopRoute = true; boolean loopHost = true; boolean loopSwitch = true; boolean loopDb = true; boolean loopMid = true; boolean loopService = true; boolean loopSecu = true; // treeBid List routelist = null; List hostlist = null; List switchlist = null; List dblist = null; List seculist = null; // List iislist = (ArrayList) session.getAttribute("iislist"); List tomcatlist = (ArrayList) session.getAttribute("tomcatlist"); List weblogiclist = (ArrayList) session.getAttribute("weblogiclist"); List waslist = (ArrayList) session.getAttribute("waslist"); List dominolist = (ArrayList) session.getAttribute("dominolist"); List mqlist = (ArrayList) session.getAttribute("mqlist"); List jbosslist = (ArrayList) session.getAttribute("jbosslist"); List apachelist = (ArrayList) session.getAttribute("apachelist"); // List socketlist = (ArrayList) session.getAttribute("socketlist"); List ftplist = (ArrayList) session.getAttribute("ftplist"); List emaillist = (ArrayList) session.getAttribute("emaillist"); List weblist = (ArrayList) session.getAttribute("weblist"); if (deviceHash.containsKey("routelist")) { routelist = (ArrayList) deviceHash.get("routelist"); } if (deviceHash.containsKey("hostlist")) { hostlist = (ArrayList) deviceHash.get("hostlist"); } if (deviceHash.containsKey("switchlist")) { switchlist = (ArrayList) deviceHash.get("switchlist"); } if (deviceHash.containsKey("dblist")) { dblist = (List) deviceHash.get("dblist"); } if (deviceHash.containsKey("seculist")) { seculist = (ArrayList) deviceHash.get("seculist"); } for (int i = 0; i < bidsArr.length; i++) { if (bidsArr[i] != null && !bidsArr[i].equals("")) { // if (routelist != null && loopRoute) { for (int j = 0; j < routelist.size(); j++) { HostNode node = (HostNode) routelist.get(j); if (node != null && node.getBid() != null && !node.getBid().contains(bidsArr[i])) { // continue; } else { // treeBidRouter = bidsArr[i]; loopRoute = false; break; } } } // if (hostlist != null && loopHost) { for (int j = 0; j < hostlist.size(); j++) { HostNode node = (HostNode) hostlist.get(j); if (node != null && node.getBid() != null && !node.getBid().contains(bidsArr[i])) { // continue; } else { // treeBidHost = bidsArr[i]; loopHost = false; break; } } } // if (switchlist != null && loopSwitch) { for (int j = 0; j < switchlist.size(); j++) { HostNode node = (HostNode) switchlist.get(j); if (node != null && node.getBid() != null && !node.getBid().contains(bidsArr[i])) { // continue; } else { // treeBidSwitch = bidsArr[i]; loopSwitch = false; break; } } } // if (dblist != null && loopDb) { for (int j = 0; j < dblist.size(); j++) { DBVo node = (DBVo) dblist.get(j); if (node != null && node.getBid() != null && !node.getBid().contains(bidsArr[i])) { // continue; } else { // treeBidDb = bidsArr[i]; loopDb = false; break; } } } // if (loopMid) { if (iislist != null && loopMid) { for (int j = 0; j < iislist.size(); j++) { IISConfig node = (IISConfig) iislist.get(j); if (node != null && node.getNetid() != null && !node.getNetid().contains(bidsArr[i])) { // continue; } else { // treeBidMid = bidsArr[i]; loopMid = false; break; } } } if (tomcatlist != null && loopMid) { for (int j = 0; j < tomcatlist.size(); j++) { Tomcat node = (Tomcat) tomcatlist.get(j); if (node != null && node.getBid() != null && !node.getBid().contains(bidsArr[i])) { // continue; } else { // treeBidMid = bidsArr[i]; loopDb = false; break; } } } if (weblogiclist != null && loopMid) { for (int j = 0; j < weblogiclist.size(); j++) { WeblogicConfig node = (WeblogicConfig) weblogiclist.get(j); if (node != null && node.getNetid() != null && !node.getNetid().contains(bidsArr[i])) { // continue; } else { // treeBidMid = bidsArr[i]; loopDb = false; break; } } } if (waslist != null && loopMid) { for (int j = 0; j < waslist.size(); j++) { WasConfig node = (WasConfig) waslist.get(j); if (node != null && node.getNetid() != null && !node.getNetid().contains(bidsArr[i])) { // continue; } else { // treeBidMid = bidsArr[i]; loopDb = false; break; } } } if (dominolist != null && loopMid) { for (int j = 0; j < dominolist.size(); j++) { DominoConfig node = (DominoConfig) dominolist.get(j); if (node != null && node.getNetid() != null && !node.getNetid().contains(bidsArr[i])) { // continue; } else { // treeBidMid = bidsArr[i]; loopDb = false; break; } } } if (mqlist != null && loopMid) { for (int j = 0; j < mqlist.size(); j++) { MQConfig node = (MQConfig) mqlist.get(j); if (node != null && node.getNetid() != null && !node.getNetid().contains(bidsArr[i])) { // continue; } else { // treeBidMid = bidsArr[i]; loopDb = false; break; } } } if (jbosslist != null && loopMid) { for (int j = 0; j < jbosslist.size(); j++) { JBossConfig node = (JBossConfig) jbosslist.get(j); if (node != null && node.getNetid() != null && !node.getNetid().contains(bidsArr[i])) { // continue; } else { // treeBidMid = bidsArr[i]; loopDb = false; break; } } } if (apachelist != null && loopMid) { for (int j = 0; j < apachelist.size(); j++) { ApacheConfig node = (ApacheConfig) apachelist.get(j); if (node != null && node.getNetid() != null && !node.getNetid().contains(bidsArr[i])) { // continue; } else { // treeBidMid = bidsArr[i]; loopDb = false; break; } } } } // if (loopService) { if (socketlist != null && loopService) { for (int j = 0; j < socketlist.size(); j++) { PSTypeVo node = (PSTypeVo) socketlist.get(j); if (node != null && node.getBid() != null && !node.getBid().contains(bidsArr[i])) { // continue; } else { // treeBidService = bidsArr[i]; loopService = false; break; } } } if (ftplist != null && loopService) { for (int j = 0; j < ftplist.size(); j++) { FTPConfig node = (FTPConfig) ftplist.get(j); if (node != null && node.getBid() != null && !node.getBid().contains(bidsArr[i])) { // FTP continue; } else { // treeBidService = bidsArr[i]; loopService = false; break; } } } if (emaillist != null && loopService) { for (int j = 0; j < emaillist.size(); j++) { EmailMonitorConfig node = (EmailMonitorConfig) emaillist.get(j); if (node != null && node.getBid() != null && !node.getBid().contains(bidsArr[i])) { // continue; } else { // treeBidService = bidsArr[i]; loopService = false; break; } } } if (weblist != null && loopService) { for (int j = 0; j < weblist.size(); j++) { WebConfig node = (WebConfig) weblist.get(j); if (node != null && node.getNetid() != null && !node.getNetid().contains(bidsArr[i])) { // continue; } else { // treeBidService = bidsArr[i]; loopService = false; break; } } } } // if (seculist != null && loopSecu) { for (int j = 0; j < seculist.size(); j++) { HostNode node = (HostNode) seculist.get(j); if (node != null && node.getBid() != null && !node.getBid().contains(bidsArr[i])) { // continue; } else { // treeBidSecu = bidsArr[i]; loopSecu = false; break; } } } } } treeBidHash.put("treeBidRouter", treeBidRouter); treeBidHash.put("treeBidHost", treeBidHost); treeBidHash.put("treeBidSwitch", treeBidSwitch); treeBidHash.put("treeBidDb", treeBidDb); treeBidHash.put("treeBidMid", treeBidMid); treeBidHash.put("treeBidService", treeBidService); treeBidHash.put("treeBidSecu", treeBidSecu); return treeBidHash; }
From source file:com.enonic.vertical.engine.handlers.MenuHandler.java
/** * Builds a menu tree, typically used to present the menu in the menu ;) * * @param user The current user * @param getterSettings If given - build tree from these settings * @return A DOM document containing the menu tree *///w w w . ja va 2 s. co m public Document getMenusForAdmin(User user, MenuGetterSettings getterSettings) { List<Integer> paramValues = new ArrayList<Integer>(2); StringBuffer sqlMenus = new StringBuffer(MENU_SELECT); if (getterSettings.hasMenuKeys()) { int[] menuKeys = getterSettings.getMenuKeys(); sqlMenus.append(" WHERE "); sqlMenus.append("men_lKey IN ("); for (int i = 0; i < menuKeys.length; i++) { if (i > 0) { sqlMenus.append(','); } sqlMenus.append(menuKeys[i]); } sqlMenus.append(')'); } // Selekterer bare menyer som brukeren har create eller administrate p if (user != null) { MenuCriteria criteria = getterSettings.getMenuCriteria(); getSecurityHandler().appendMenuSQL(user, sqlMenus, criteria); } Hashtable<String, Element> hashtable_menus = new Hashtable<String, Element>(); Connection con = null; PreparedStatement statement = null; ResultSet resultSet = null; Document doc = XMLTool.createDocument("menus"); try { con = getConnection(); statement = con.prepareStatement(sqlMenus.toString()); JDBCUtil.addValuesToPreparedStatement(statement, paramValues); try { // Frst selekterer vi ut menus... resultSet = statement.executeQuery(); while (resultSet.next()) { int curMenuKey = resultSet.getInt("men_lKey"); Element element_Menu = getMenuData(doc.getDocumentElement(), curMenuKey); Element accessRights = XMLTool.createElement(doc, element_Menu, "accessrights"); getSecurityHandler().appendAccessRightsOnDefaultMenuItem(user, curMenuKey, accessRights, true); XMLTool.createElement(doc, element_Menu, "menuitems"); // Lagrer referansen til kategori-elementet for raskt oppslag til senere bruk hashtable_menus.put(String.valueOf(curMenuKey), element_Menu); } } finally { close(resultSet); resultSet = null; close(statement); statement = null; } MenuItemCriteria menuItemCriteria = getterSettings.getMenuItemCriteria(); if (!menuItemCriteria.getDisableMenuItemLoadingForUnspecified() || menuItemCriteria.getMenuKey() >= 0) { // Legger s til menuitems til menyene Hashtable<String, Element> hashtable_MenuItems = appendMenuItemsBySettings(user, doc, hashtable_menus, getterSettings); // Hvis brukeren bare vil ha et fullt tree fra gitte menuItemKey, // s m vi fjerne alle ssken-noder til foreldre-nodene if (getterSettings.hasOnlyChildrenFromThisMenuItemKey()) { Element curMenuItem = hashtable_MenuItems .get(getterSettings.getMenuItemKeyAsInteger().toString()); while (curMenuItem != null) { XMLTool.removeAllSiblings(curMenuItem); // Move to first parent node (menuitems) curMenuItem = (Element) curMenuItem.getParentNode(); // Exit loop if we have reached the top if ("menus".equals(curMenuItem.getNodeName())) { break; } // Move to next parent node (menuitem/menu) if (curMenuItem != null) { curMenuItem = (Element) curMenuItem.getParentNode(); } } } if (getterSettings.hasTagParentsOfThisMenuItem()) { Element menuItem = hashtable_MenuItems .get(getterSettings.getTagParentsOfThisMenuItemKeyAsInteger().toString()); Node parent = menuItem.getParentNode(); String tagName = getterSettings.getTagParentsOfThisMenuItemTagName(); String tagValue = getterSettings.getTagParentsOfThisMenuItemTagValue(); while (parent != null) { if (parent instanceof Element) { ((Element) parent).setAttribute(tagName, tagValue); } parent = parent.getParentNode(); } } } if (!getterSettings.hasMenuKeys()) { String sqlMenuItems; sqlMenuItems = "SELECT DISTINCT mei_men_lKey FROM tMenuItem JOIN tMenu on tMenuItem.mei_men_lKey = tMenu.men_lKey "; sqlMenuItems = getSecurityHandler().appendMenuItemSQL(user, sqlMenuItems, menuItemCriteria); statement = con.prepareStatement(sqlMenuItems); resultSet = statement.executeQuery(); while (resultSet.next()) { String menuKey = resultSet.getString("mei_men_lKey"); if (!hashtable_menus.containsKey(menuKey)) { Element menuElement = getMenuData(doc.getDocumentElement(), Integer.parseInt(menuKey)); hashtable_menus.put(menuKey, menuElement); } } } } catch (SQLException sqle) { String message = "Failed to get the menus: %t"; VerticalEngineLogger.error(this.getClass(), 0, message, sqle); doc = XMLTool.createDocument("categories"); } finally { close(resultSet); close(statement); close(con); } return doc; }