List of usage examples for java.util Hashtable size
public synchronized int size()
From source file:edu.ku.brc.specify.utilapps.RegisterApp.java
/** * @param catName//from w w w. jav a 2 s . c o m */ protected void fillUsageItemsList(final String catName) { String sql = "SELECT Name, Total FROM (SELECT Name, SUM(CountAmt) as Total FROM trackitem WHERE CountAmt < 100000 AND SUBSTRING(Name, 1, 8) = 'Usage_" + catName + "' GROUP BY Name) AS T1 ORDER BY Total"; System.out.println(sql); Vector<Object[]> rows = BasicSQLUtils.query(sql); DefaultListModel model = (DefaultListModel) trackItemsList.getModel(); if (rows != null && rows.size() > 0) { boolean isCatOK = catName.length() == 2; boolean isDataEntry = catName.equals("DE"); boolean isDatabase = catName.equals("DB"); Hashtable<String, Boolean> clsHash = new Hashtable<String, Boolean>(); Vector<Pair<String, Integer>> values = new Vector<Pair<String, Integer>>(); int total = 0; for (Object[] colData : rows) { String name = (String) colData[0]; int val = ((BigDecimal) colData[1]).intValue(); if (name.startsWith("Usage_")) { name = name.substring(6); } String str; if (isCatOK && name.charAt(2) == '_') { str = name.substring(catName.length() + 1); /*if (str.startsWith(catName) && str.charAt(2) == '_') { str = str.substring(catName.length()+1); }*/ if (str.startsWith("VIEW_")) { str = str.substring(5); } if (isDataEntry) { String clsName = str; if (clsName.endsWith("_RS")) { clsName = clsName.substring(0, clsName.length() - 3); } clsHash.put(clsName, true); } else if (isDatabase) { int inx = str.lastIndexOf('_'); String clsName = str.substring(inx + 1); clsHash.put(clsName, true); } } else { str = name; } values.add(new Pair<String, Integer>(str, val)); total += val; } Collections.sort(values, countComparator); createBarChart(trackDescHash.get(catName), "Actions", values); // Fill Model model.clear(); sql = "SELECT DISTINCT(Name) FROM trackitem WHERE SUBSTRING(Name, 1, 8) = 'Usage_" + catName + "' ORDER BY Name"; rows = BasicSQLUtils.query(sql); if (rows != null && rows.size() > 0) { for (Object[] colData : rows) { model.addElement(colData[0]); } } if (clsHash.size() > 0) { showClassList(clsHash); } else if (classFrame != null && classFrame.isVisible()) { classFrame.setVisible(false); } } else { model.clear(); if (chartFrame != null && chartFrame.isVisible()) { chartFrame.setVisible(false); } } }
From source file:ca.queensu.cs.sail.mailboxmina2.main.modules.ThreadsModule.java
/** * This heuristic creates associations based on the subject and a time * window Default Time window is 1 month */// w ww.j av a 2 s . c o m private void heuristicSubject(List<MM2Message> messages, Connection connection) { // This is the msg_id ==> Date Hashtable<String, Date> msg_id_to_date = new Hashtable<String, Date>(); // This is (original) subject ==> msg_id Hashtable<String, String> subject_to_msg_id = new Hashtable<String, String>(); // This is msg_id ==> (processed) subject Hashtable<String, String> msg_id_to_subject = new Hashtable<String, String>(); // This is child ==> parent Hashtable<String, String> msg_id_to_msg_id = new Hashtable<String, String>(); // Capture the most commong reply patterns // Fw: Re: Aw: Wg: Pattern reply_pattern = Pattern.compile( "^(\\[.*?\\] )?(([rR][eE]:)|([aA][wW]:)|([fF][wW]:)|([wW][gG]:)|([fF][wW][dD]:)|([wW][tT][rR]:)|([aA]ntwort:))(.*?)$"); try { for (MM2Message msg : messages) { String msg_id = msg.getHeaderEntry("msg_id"); msg_id_to_date.put(msg_id, msg.getMsg_date()); // We assume the subject to be at least "" String raw_subject = msg.getSubject(); // Determine whether the subject describes a reply or an original posting Matcher matcher = reply_pattern.matcher(raw_subject); if (matcher.matches()) { String stripped_subject = matcher.group(matcher.groupCount()); Main.getLogger().debug(5, this, "I think message is a reply and the original subject is: " + stripped_subject.trim()); // Store the information in the forward table msg_id_to_subject.put(msg_id, stripped_subject.trim()); } else { // We think that this is not a reply - hence it must be an original posting ;-) subject_to_msg_id.put(raw_subject, msg_id); Main.getLogger().debug(5, this, "I think message is an original posting: " + raw_subject.trim()); } } // Now we need to find parent relations by subject. // Still we will apply a sliding window approach using a given offset // to make sure, we don't capture events of people re-using old subject names for (String child_msg_id : msg_id_to_subject.keySet()) { String origSubj = msg_id_to_subject.get(child_msg_id); String parent_msg_id = subject_to_msg_id.get(origSubj); // If we found an entry in the table if (parent_msg_id != null) { // Check if the potential parent is (OFFSET) older than child Date d1 = msg_id_to_date.get(parent_msg_id); Date d2 = DateUtils.addMonths(msg_id_to_date.get(child_msg_id), OFFSET); if (d1.compareTo(d2) >= 0) { Main.getLogger().debug(5, this, "I know that message " + child_msg_id + " has the parent " + parent_msg_id); msg_id_to_msg_id.put(child_msg_id, parent_msg_id); } } } Main.getLogger().debug(5, "original posting subjects resolved = " + subject_to_msg_id.size()); Main.getLogger().debug(5, "subjects resolved replys = " + msg_id_to_subject.size()); // Store the parents and roots into the database Main.getLogger().log("The heuristic could resolve " + msg_id_to_msg_id.size() + " parent relations!"); Main.getLogger().log("Storing associations found by in-reply-to heuristic in the database..."); storeParents(msg_id_to_msg_id, connection); } catch (Exception e) { Main.getLogger().error("Error storing messages for heuristic in-reply!", e); } }
From source file:org.hdiv.filter.ValidatorHelperRequest.java
/** * Checks if the values of the parameters received in the request <code>request</code> are valid. These values are * valid if and only if the noneditable parameters haven't been modified.<br> * Validation process is as follows.<br> * 1. If the action to which the request is directed is an init page, then it is a valid request.<br> * 2. if the cookies received in the request are not found in the user session, the validation is incorrect.<br> * 3. if the state recover process has produced an error, incorrect validation.<br> * 4. If the action received in the request is different to the action of the recovered state, incorrect validation.<br> * 5. If not, all the parameter values are checked and if all the received values are valid then the request is * valid. <br>/* www . j a v a 2 s. c om*/ * 5.1. If it is an init parameter or a HDIV parameter then it is a valid parameter.<br> * 5.2. If the received parameter is not in the state:<br> * 5.2.1. If it has been defined by the user as a no validation required parameter, then it is a valid parameter.<br> * 5.2.2. otherwise, it is a no valid request.<br> * 5.3. If the parameter is editable, if validations have been defined values are checked.<br> * 5.4. If it is a noneditable parameter, all the received values are checked. * * @param request * HttpServletRequest to validate * @return valid result If all the parameter values of the request <code>request</code> pass the the HDIV * validation. False, otherwise. * @throws HDIVException * If the request doesn't pass the HDIV validation an exception is thrown explaining the cause of the * error. */ public ValidatorHelperResult validate(HttpServletRequest request) { String target = this.getTarget(request); String targetWithoutContextPath = this.getTargetWithoutContextPath(request, target); // Hook before the validation Boolean pre = this.preValidate(request, target); if (pre != null) { return new ValidatorHelperResult(pre.booleanValue()); } if (this.hdivConfig.hasExtensionToExclude(target)) { log.debug("The target " + target + " has an extension to exclude from validation"); return ValidatorHelperResult.VALID; } if (!this.hdivConfig.isValidationInUrlsWithoutParamsActivated()) { boolean requestHasParameters = (request.getParameterNames() != null) && (request.getParameterNames().hasMoreElements()); if (!requestHasParameters) { log.debug("The url " + request.getRequestURI() + " is not be validated because it has not got parameters"); return ValidatorHelperResult.VALID; } } if (this.hdivConfig.isStartPage(targetWithoutContextPath, request.getMethod())) { return (this.validateStartPageParameters(request, target)); } if (this.hdivConfig.isCookiesIntegrityActivated()) { ValidatorHelperResult result = this.validateRequestCookies(request, target); if (!result.isValid()) { return result; } } // Restore state from request or from memory ValidatorHelperResult result = this.restoreState(request, target); if (!result.isValid()) { return result; } // Get resultant object, the stored state IState state = (IState) result.getValue(); result = this.isTheSameAction(request, target, state); if (!result.isValid()) { return result; } result = this.allRequiredParametersReceived(request, state, target); if (!result.isValid()) { return result; } // Hdiv parameter name String hdivParameter = getHdivParameter(request); Hashtable unauthorizedEditableParameters = new Hashtable(); Enumeration parameters = request.getParameterNames(); while (parameters.hasMoreElements()) { String parameter = (String) parameters.nextElement(); // Check if the HDIV validation must be applied to the parameter if (!this.hdivConfig.needValidation(parameter, hdivParameter)) { if (log.isDebugEnabled() && !parameter.equals(hdivParameter)) { log.debug("parameter " + parameter + " doesn't need validation"); } continue; } // If the parameter requires no validation it is considered a valid parameter if (this.isUserDefinedNonValidationParameter(targetWithoutContextPath, parameter)) { continue; } IParameter stateParameter = state.getParameter(parameter); if (stateParameter == null) { // If the parameter is not defined in the state, it is an error. // With this verification we guarantee that no extra parameters are added. this.logger.log(HDIVErrorCodes.PARAMETER_NOT_EXISTS, target, parameter, null); if (log.isDebugEnabled()) { log.debug("Validation Error Detected: Parameter [" + parameter + "] does not exist in the state for action [" + target + "]"); } return new ValidatorHelperResult(HDIVErrorCodes.PARAMETER_NOT_EXISTS); } // At this point we are processing a noneditable parameter String[] values = request.getParameterValues(parameter); // Check if the parameter is editable if (stateParameter.isEditable()) { if (hdivConfig.existValidations() && (stateParameter.getEditableDataType() != null)) { this.validateEditableParameter(request, target, parameter, values, stateParameter.getEditableDataType(), unauthorizedEditableParameters); } continue; } try { result = this.validateParameterValues(request, target, state, stateParameter, parameter, values); if (!result.isValid()) { return result; } } catch (Exception e) { String errorMessage = HDIVUtil.getMessage("validation.error", e.getMessage()); throw new HDIVException(errorMessage, e); } } if (unauthorizedEditableParameters.size() > 0) { return this.processValidateParameterErrors(request, unauthorizedEditableParameters); } return ValidatorHelperResult.VALID; }
From source file:org.tinygroup.jspengine.compiler.TagLibraryInfoImpl.java
private void parseTLD(JspCompilationContext ctxt, String uri, InputStream in, URL jarFileUrl) throws JasperException { Vector tagVector = new Vector(); Vector tagFileVector = new Vector(); Hashtable functionTable = new Hashtable(); // Create an iterator over the child elements of our <taglib> element ParserUtils pu = new ParserUtils(); TreeNode tld = pu.parseXMLDocument(uri, in); // Check to see if the <taglib> root element contains a 'version' // attribute, which was added in JSP 2.0 to replace the <jsp-version> // subelement this.jspversion = tld.findAttribute("version"); // Process each child element of our <taglib> element Iterator list = tld.findChildren(); while (list.hasNext()) { TreeNode element = (TreeNode) list.next(); String tname = element.getName(); if ("tlibversion".equals(tname) // JSP 1.1 || "tlib-version".equals(tname)) { // JSP 1.2 this.tlibversion = element.getBody(); } else if ("jspversion".equals(tname) || "jsp-version".equals(tname)) { this.jspversion = element.getBody(); } else if ("shortname".equals(tname) || "short-name".equals(tname)) this.shortname = element.getBody(); else if ("uri".equals(tname)) this.urn = element.getBody(); else if ("info".equals(tname) || "description".equals(tname)) this.info = element.getBody(); else if ("validator".equals(tname)) this.tagLibraryValidator = createValidator(element); else if ("tag".equals(tname)) tagVector.addElement(createTagInfo(element, jspversion)); else if ("tag-file".equals(tname)) { TagFileInfo tagFileInfo = createTagFileInfo(element, uri, jarFileUrl); tagFileVector.addElement(tagFileInfo); } else if ("function".equals(tname)) { // JSP2.0 FunctionInfo funcInfo = createFunctionInfo(element); String funcName = funcInfo.getName(); if (functionTable.containsKey(funcName)) { err.jspError("jsp.error.tld.fn.duplicate.name", funcName, uri); }//from w ww. j a v a 2 s. com functionTable.put(funcName, funcInfo); } else if ("display-name".equals(tname) || // Ignored elements "small-icon".equals(tname) || "large-icon".equals(tname) || "listener".equals(tname)) { ; } else if ("taglib-extension".equals(tname)) { // Recognized but ignored } else { err.jspError("jsp.error.unknown.element.in.taglib", tname); } } if (tlibversion == null) { err.jspError("jsp.error.tld.mandatory.element.missing", "tlib-version"); } if (jspversion == null) { err.jspError("jsp.error.tld.mandatory.element.missing", "jsp-version"); } this.tags = new TagInfo[tagVector.size()]; tagVector.copyInto(this.tags); this.tagFiles = new TagFileInfo[tagFileVector.size()]; tagFileVector.copyInto(this.tagFiles); this.functions = new FunctionInfo[functionTable.size()]; int i = 0; Enumeration enumeration = functionTable.elements(); while (enumeration.hasMoreElements()) { this.functions[i++] = (FunctionInfo) enumeration.nextElement(); } }
From source file:ca.queensu.cs.sail.mailboxmina2.main.modules.ThreadsModule.java
/** * This heuristic creates associations based on the in-reply: header field * of messages/*from w ww.j a va 2 s. c om*/ */ private void heuristicInreply(List<MM2Message> messages, Connection connection) { // This is the msg_id ==> in-reply-to Hashtable<String, String> msg_id_to_message_id = new Hashtable<String, String>(); // This is message-id ==> msg_id Hashtable<String, String> message_id_to_msg_id = new Hashtable<String, String>(); // This is child ==> parent Hashtable<String, String> msg_id_to_msg_id = new Hashtable<String, String>(); Pattern messageid_pattern = Pattern.compile("<(.*?@.*?)>"); try { for (MM2Message msg : messages) { // Step One: check whether the message has a message-id header // We assume that the "message-id" field is always set - at least to "" and is not null String h_message_id = msg.getHeaderEntry("message-id"); if (h_message_id.length() > 2) { // We try to identify the message identifier part String maybeMatch = findLongestPatternMatch(h_message_id, messageid_pattern); if (!maybeMatch.equalsIgnoreCase("")) { String extracted_message_id = maybeMatch; String msg_id = msg.getHeaderEntry("msg_id"); // Add the information to the reverse lookup table that we will need later message_id_to_msg_id.put(extracted_message_id, msg_id); Main.getLogger().debug(5, this, "I know that message " + msg_id + " has message-id " + extracted_message_id); } } // Step Two: check whether the message has an in-reply-to header // Again we assume that the "in-reply-to" field is at least "" and not null String h_in_reply_to = msg.getHeaderEntry("in-reply-to"); if (h_in_reply_to.contains(">") && h_in_reply_to.contains("<")) { // We try to identify the message identifier part String maybeMatch = findLongestPatternMatch(h_in_reply_to, messageid_pattern); if (!maybeMatch.equalsIgnoreCase("")) { String extracted_in_reply_to_messageid = maybeMatch; String msg_id = msg.getHeaderEntry("msg_id"); // Add the information into the forward lookup table Main.getLogger().debug(5, this, "I know that message " + msg_id + " is a reply to " + extracted_in_reply_to_messageid); msg_id_to_message_id.put(msg_id, extracted_in_reply_to_messageid); } } } // Step Three: After we obtained the previous information, we will // resolve each in-reply-to id to a msg_id. so we know for each key in the // forward lookup table the msg_id it is a reply to: for (String child_msg_id : msg_id_to_message_id.keySet()) { String parent_msg_id = message_id_to_msg_id.get(msg_id_to_message_id.get(child_msg_id)); // If we found an entry in the table if (parent_msg_id != null) { // Add this information to the parents table Main.getLogger().debug(5, this, "I know that message " + child_msg_id + " has the parent " + parent_msg_id); msg_id_to_msg_id.put(child_msg_id, parent_msg_id); } } Main.getLogger().debug(5, "message-ids resolved to msg_ids = " + message_id_to_msg_id.size()); Main.getLogger().debug(5, "message_ids resolved from in-reply-to = " + msg_id_to_message_id.size()); // Store the parents and roots into the database Main.getLogger().log("The heuristic could resolve " + msg_id_to_msg_id.size() + " parent relations!"); Main.getLogger().log("Storing associations found by in-reply-to heuristic in the database..."); storeParents(msg_id_to_msg_id, connection); } catch (Exception e) { Main.getLogger().error("Error storing messages for heuristic in-reply!", e); } }
From source file:com.hexidec.ekit.EkitCore.java
/** * Method for inserting a form element//from w ww. ja va 2 s . c om */ private void insertFormElement(HTML.Tag baseTag, String baseElement, Hashtable attribs, String[] fieldNames, String[] fieldTypes, String[] fieldValues, boolean hasClosingTag) throws IOException, BadLocationException, RuntimeException { int caretPos = jtpMain.getCaretPosition(); StringBuffer compositeElement = new StringBuffer("<" + baseElement); if (attribs != null && attribs.size() > 0) { Enumeration attribEntries = attribs.keys(); while (attribEntries.hasMoreElements()) { Object entryKey = attribEntries.nextElement(); Object entryValue = attribs.get(entryKey); if (entryValue != null && entryValue != "") { compositeElement.append(" " + entryKey + "=" + '"' + entryValue + '"'); } } } if (fieldNames != null && fieldNames.length > 0) { PropertiesDialog propertiesDialog = new PropertiesDialog(this.getWindow(), fieldNames, fieldTypes, fieldValues, Translatrix.getTranslationString("FormDialogTitle"), true); propertiesDialog.setVisible(true); String decision = propertiesDialog.getDecisionValue(); if (decision.equals(Translatrix.getTranslationString("DialogCancel"))) { propertiesDialog.dispose(); propertiesDialog = null; return; } else { for (String fieldName : fieldNames) { String propValue = propertiesDialog.getFieldValue(fieldName); if (propValue != null && propValue.length() > 0) { if (fieldName.equals("checked")) { if (propValue.equals("true")) { compositeElement.append(" " + fieldName + "=" + '"' + propValue + '"'); } } else { compositeElement.append(" " + fieldName + "=" + '"' + propValue + '"'); } } } } propertiesDialog.dispose(); propertiesDialog = null; } // --- Convenience for editing, this makes the FORM visible if (useFormIndicator && baseElement.equals("form")) { compositeElement.append(" bgcolor=" + '"' + clrFormIndicator + '"'); } // --- END compositeElement.append(">"); if (baseTag == HTML.Tag.FORM) { compositeElement.append("<P> </P>"); compositeElement.append("<P> </P>"); compositeElement.append("<P> </P>"); } if (hasClosingTag) { compositeElement.append("</" + baseElement + ">"); } if (baseTag == HTML.Tag.FORM) { compositeElement.append("<P> </P>"); } htmlKit.insertHTML(htmlDoc, caretPos, compositeElement.toString(), 0, 0, baseTag); // jtpMain.setCaretPosition(caretPos + 1); refreshOnUpdate(); }
From source file:ca.queensu.cs.sail.mailboxmina2.main.modules.ThreadsModule.java
/** * This heuristic creates associations based on the references header fields *//*from w w w . j av a2 s. c o m*/ private void heuristicReferences(List<MM2Message> messages, Connection connection) { // This is the msg_id ==> references-id Hashtable<String, String> msg_id_to_message_id = new Hashtable<String, String>(); // This is message-id ==> msg_id Hashtable<String, String> message_id_to_msg_id = new Hashtable<String, String>(); // This is child ==> parent Hashtable<String, String> msg_id_to_msg_id = new Hashtable<String, String>(); Pattern messageid_pattern = Pattern.compile("<(.*?@.*?)>"); try { for (MM2Message msg : messages) { // Step One: check whether the message has a message-id header // We assume that the "message-id" field is always set - at least to "" and is not null String h_message_id = msg.getHeaderEntry("message-id"); if (h_message_id.length() > 2) { // We try to identify the message identifier part String maybeMatch = findLongestPatternMatch(h_message_id, messageid_pattern); if (!maybeMatch.equalsIgnoreCase("")) { String extracted_message_id = maybeMatch; String msg_id = msg.getHeaderEntry("msg_id"); // Add the information to the reverse lookup table that we will need later message_id_to_msg_id.put(extracted_message_id, msg_id); Main.getLogger().debug(5, this, "I know that message " + msg_id + " has message-id " + extracted_message_id); } } // Step Two: check whether the message has an references header // Again we assume that the "references" field is at least "" and not null String h_references = msg.getHeaderEntry("references"); String[] split_refs = h_references.split(" "); for (String ref : split_refs) { if (ref.contains(">") && ref.contains("<")) { // We try to identify the message identifier part String maybeMatch = findLongestPatternMatch(h_references, messageid_pattern); if (!maybeMatch.equalsIgnoreCase("")) { String extracted_in_reply_to_messageid = maybeMatch; String msg_id = msg.getHeaderEntry("msg_id"); // Add the information into the forward lookup table Main.getLogger().debug(5, this, "I know that message " + msg_id + " is a reply to " + extracted_in_reply_to_messageid); msg_id_to_message_id.put(msg_id, extracted_in_reply_to_messageid); } } } } // Step Three: After we obtained the previous information, we will // resolve each in-reply-to id to a msg_id. so we know for each key in the // forward lookup table the msg_id it is a reply to: for (String child_msg_id : msg_id_to_message_id.keySet()) { String parent_msg_id = message_id_to_msg_id.get(msg_id_to_message_id.get(child_msg_id)); // If we found an entry in the table if (parent_msg_id != null) { // Add this information to the parents table Main.getLogger().debug(5, this, "I know that message " + child_msg_id + " has the parent " + parent_msg_id); msg_id_to_msg_id.put(child_msg_id, parent_msg_id); } } Main.getLogger().debug(5, "message-ids resolved to msg_ids = " + message_id_to_msg_id.size()); Main.getLogger().debug(5, "message_ids resolved from references = " + msg_id_to_message_id.size()); // Store the parents and roots into the database Main.getLogger().log("The heuristic could resolve " + msg_id_to_msg_id.size() + " parent relations!"); Main.getLogger().log("Storing associations found by references heuristic in the database..."); storeParents(msg_id_to_msg_id, connection); } catch (Exception e) { Main.getLogger().error("Error storing messages for heuristic references!", e); } }
From source file:org.kepler.kar.KARFile.java
/** * Here we go through all the KAREntries and call the open method of the * appropriate KAREntryHandlers. It is assumed that cacheKARContents() has * been called at some point before openKAR() In other words everything in * the kar is already cached when calling the open() method of the * KAREntryHandlers.//from w w w . j a v a 2 s. c o m * * Note: There is some issue with having this method here, since it is * really a gui specific function it probably does not belong here in the * core module. * * @param tableauFrame * @param forceOpen * @throws Exception * @returns true if at least one of the entries in the KAR was opened */ public boolean openKARContents(TableauFrame tableauFrame, boolean forceOpen) throws Exception { if (isDebugging) log.debug("openKAR: " + this.toString()); if (!forceOpen && !isOpenable()) { return false; } try { /** * Loop through the kar entries and call the open method of the * appropriate KAREntryHandler */ Vector<KAREntry> unopenedEntries = (Vector<KAREntry>) karEntries(); Hashtable<KeplerLSID, KAREntry> openedEntries = new Hashtable<KeplerLSID, KAREntry>(); // keep cycling through the unopened entries until the list is empty while (unopenedEntries.size() > 0) { // keep track of the entries that were opened during this pass Vector<KAREntry> openedThisPass = new Vector<KAREntry>(unopenedEntries.size()); // cycle through all of the remaining, unopened entries for (KAREntry entry : unopenedEntries) { if (isDebugging) { log.debug(entry.getName()); } // get the dependency list for this entry List<KeplerLSID> depList = entry.getLsidDependencies(); if (depList.size() == 0) { // if there are no dependencies we just open it up boolean success = open(entry, tableauFrame); if (success) { openedEntries.put(entry.getLSID(), entry); openedThisPass.add(entry); break; } if (isDebugging) log.debug(success); } else { // if there are dependencies then we check to make sure // that all of the dependencies have already been opened boolean allDependenciesHaveBeenOpened = true; for (KeplerLSID lsid : depList) { // if any of the dependencies have not been opened, // set false if (!openedEntries.containsKey(lsid)) { allDependenciesHaveBeenOpened = false; } } if (allDependenciesHaveBeenOpened) { // dependencies have been opened so OK to open this // one boolean success = open(entry, tableauFrame); if (success) { openedEntries.put(entry.getLSID(), entry); openedThisPass.add(entry); break; } if (isDebugging) log.debug(success); } } } if (openedThisPass.size() == 0) { // Bad news, nothing is getting opened // break out to avoid infinite loop break; } // remove the entries that were opened during this pass for (KAREntry entry : openedThisPass) { unopenedEntries.remove(entry); } } if (openedEntries.size() == 0) { return false; } } catch (Exception e) { throw new Exception("Error on Open: " + e.getMessage()); } return true; }
From source file:com.globalsight.everest.workflowmanager.WorkflowManagerLocal.java
private void modifyTasks(Session p_session, Hashtable p_modifiedTasks, Workflow p_workflow, List p_wfTaskInfos) throws Exception { Task task = null;/* w w w . ja v a 2s . c o m*/ try { // if there are modified tasks if (p_modifiedTasks != null && p_modifiedTasks.size() > 0) { Collection modifiedTasks = p_modifiedTasks.values(); for (Iterator i = modifiedTasks.iterator(); i.hasNext();) { TaskInfoBean taskInfo = (TaskInfoBean) i.next(); // Get a task from Toplink task = ServerProxy.getTaskManager().getTask(taskInfo.getTaskId()); // since we can also modify a workflow in Ready state, we // need // to check before deletion (in Ready state Task has not // been // created yet). if (task != null) { task = modifyTask(task, taskInfo, p_session); } } if (s_logger.isDebugEnabled()) { s_logger.debug("modifyTasks : " + " workflow=" + p_workflow.getId() + " Task=" + WorkflowHelper.toDebugString(task) + GlobalSightCategory.getLineContinuation() + " task=" + task.toString()); } } } catch (Exception e) { s_logger.error("Failed to get a rate for a task.", e); // if a task was set then specify the task - otherwise specify all // because // the costing engine couldn't be retrieved to get rates. String taskId = task != null ? Long.toString(task.getId()) : "all"; String args[] = { taskId }; throw new WorkflowManagerException(WorkflowManagerException.MSG_FAILED_TO_FIND_RATE_FOR_TASK, args, e); } }
From source file:com.crushpaper.DbLogic.java
/** * API method. Starts its own transaction. Returns true if the DB is * internally consistent. If this returns true then either: 1) there is a * bug in the application code, 2) there is a bug in the DB code, 3) the DB * was tampered with by another application 4) the DB has been corrupted. *//* www.ja v a2s. c om*/ public boolean hasErrors(Errors errors) { if (errors == null) return false; // Iterate over all entries. List<?> entries = getAllEntries(); for (Object entryUncasted : entries) { Entry entry = (Entry) entryUncasted; // Make sure it has an id. final String id = entry.getId(); if (id == null || id.isEmpty()) { errors.add(errorMessages.errorDbTheEntryHadNoId()); continue; } final String userId = entry.getUserId(); if (userId == null || userId.isEmpty()) { errors.add(errorMessages.errorDbTheEntryIsRelatedTheWrongNumberOfUsers(id, 0)); continue; } // Make sure it is linked to a user. User user = getUserById(userId); if (user == null) { errors.add(errorMessages.errorDbTheEntryIsRelatedTheWrongNumberOfUsers(id, 0)); continue; } Entry parent = getEntryById(entry.getParentId()); // If it has a parent id that parent must be linked. if (entry.hasParentId() && parent == null) { errors.add( errorMessages.errorDbTheEntryAParentIdButNoParentRelationship(entry.getParentId(""), id)); } // If it has a first child id then last child id must be set. if (entry.hasLastChildId() && !entry.hasFirstChildId()) { errors.add(errorMessages.errorDbTheEntryHasALastChildIdButNoFirstChildId(entry.getLastChildId(""), id)); } // If it has a last child id then first child id must be set. if (entry.hasFirstChildId() && !entry.hasLastChildId()) { errors.add(errorMessages.errorDbTheEntryHasAFirstChildIdButNoLastChildId(entry.getFirstChildId(""), id)); } // If the parent's lastChildId is this then this entry may have // no nextSiblingId. if (parent != null && parent.getLastChildId("").equals(id) && entry.hasNextSiblingId()) { errors.add(errorMessages.errorDbTheEntryIsTheParentsLastChildButHasANextSibling(id)); } // If the parent's firstChildId is this then this entry may have // no previousSiblingId. if (parent != null && parent.getFirstChildId("").equals(id) && entry.hasPreviousSiblingId()) { errors.add(errorMessages.errorDbTheEntryIsTheParentsFirstChildButHasAPreviousSibling(id)); } final Hashtable<String, Entry> children = new Hashtable<String, Entry>(); Entry firstChild = null; for (Object objectChild : getEntriesByParentId(entry.getId())) { Entry child = (Entry) objectChild; children.put(child.getId(), child); if (!child.hasPreviousSiblingId()) { if (firstChild != null) { errors.add(errorMessages.errorDbTheEntryHasMoreThanOneChildWithoutAPreviousSiblingId(id)); } firstChild = child; } } // Make sure first child is is consistent. if (entry.hasFirstChildId() && children.isEmpty()) { errors.add(errorMessages.errorDbTheEntryHasAFirstChildIdButNoChildren(id)); } if (!entry.hasFirstChildId() && !children.isEmpty()) { errors.add(errorMessages.errorDbTheEntryHasAFirstChildIdButNoChildren(id)); } if (!children.isEmpty()) { if (firstChild == null) { errors.add(errorMessages.errorDbTheEntryHasNoChildWithoutAPreviousSiblingId(id)); } else { if (!firstChild.getId("").equals(entry.getFirstChildId(""))) { errors.add(errorMessages.errorDbTheEntryHasAChildWithoutAPreviousSiblingId(id)); } } Entry child = firstChild; Entry lastChild = null; int i = 0; for (; i < children.size(); ++i) { if (child == null) { break; } if (!child.hasNextSiblingId()) { lastChild = child; break; } final String previousId = child.getId(""); final String nextId = child.getNextSiblingId(); child = children.get(nextId); if (child == null) { errors.add(errorMessages.errorDbTheEntryHasAChildWithASiblingThatIsNotRelated(id, nextId)); } else if (!child.getPreviousSiblingId("").equals(previousId)) { errors.add(errorMessages.errorDbTheEntryHasAChildWhosePreviousDoesNotMatch(id, child.getPreviousSiblingId(""), previousId)); } } if (i != children.size() - 1) { errors.add(errorMessages.errorDbTheEntryHasExtraChildren(id, children.size() - i)); } if (lastChild == null) { errors.add(errorMessages.errorDbTheEntryHasNoChildrenWithoutANextSiblingId(id)); } else { if (!lastChild.getId("").equals(entry.getLastChildId(""))) { errors.add(errorMessages.errorDbTheEntryHasAChildWithoutANextSiblingIdThatIsNotItsLastChild( id, lastChild.getId(""))); } } } } return errors.hasErrors(); }