List of usage examples for java.util Hashtable values
Collection values
To view the source code for java.util Hashtable values.
Click Source Link
From source file:com.globalsight.everest.edit.offline.upload.UploadApi.java
/** * Check the task state(Task.STATE_ACCEPTED) and task acceptor, fix for * GBS-2191//from ww w . j a v a 2 s. c o m * * @param task * @param fileName * @return */ private String checkTask(User user, Task task, String fileName) { if (task == null) { String args[] = { fileName, m_uploadPageData.getTaskId() }; String errMsg = MessageFormat.format(m_messages.getString("TaskNullError"), (Object[]) args); CATEGORY.error(errMsg); m_errWriter.addFileErrorMsg(errMsg); return m_errWriter.buildPageForTaskError().toString(); } String userId = user.getUserId(); int state = task.getState(); if (state != Task.STATE_ACCEPTED) { // Fix for GBS-2393 boolean statusError = true; PermissionSet ps = null; try { ps = Permission.getPermissionManager().getPermissionSetForUser(user.getUserId()); } catch (Exception e) { CATEGORY.error(e); } if (ps.getPermissionFor(Permission.ACTIVITIES_OFFLINEUPLOAD_FROMANYACTIVITY)) { // fetch the accepted task of this workflow if the task's // acceptor is current user Hashtable<String, Task> tasks = task.getWorkflow().getTasks(); Iterator<Task> it = tasks.values().iterator(); while (it.hasNext()) { Task tk = it.next(); if (tk.getState() == Task.STATE_ACCEPTED) { if (userId.equals(tk.getAcceptor())) { statusError = false; } break; } } } if (statusError) { String args[] = { fileName, task.getJobName(), task.getTargetLocale().toString(), String.valueOf(task.getId()) }; String errMsg = MessageFormat.format(m_messages.getString("TaskStatusError"), (Object[]) args); CATEGORY.error(errMsg); m_errWriter.addFileErrorMsg(errMsg); return m_errWriter.buildPageForTaskError().toString(); } } else { String acceptor = task.getAcceptor(); if (!userId.equals(acceptor)) { String args[] = { fileName, task.getJobName(), task.getTargetLocale().toString(), String.valueOf(task.getId()), String.valueOf(task.getAcceptor()), acceptor }; String errMsg = MessageFormat.format(m_messages.getString("TaskAcceptorError"), (Object[]) args); CATEGORY.error(errMsg); m_errWriter.addFileErrorMsg(errMsg); return m_errWriter.buildPageForTaskError().toString(); } } return null; }
From source file:edu.ku.brc.specify.config.SpecifyAppContextMgr.java
/** * @return all unique views (also returns internal views) *//* w w w. j a v a 2 s .c o m*/ public List<ViewIFace> getEntirelyAllViews() { Vector<ViewIFace> list = new Vector<ViewIFace>(); HashSet<String> viewHashSet = new HashSet<String>(); for (SpAppResourceDir appResDir : spAppResourceList) { for (ViewSetIFace vs : getViewSetList(appResDir)) { Hashtable<String, ViewIFace> vsHash = vs.getViews(); for (ViewIFace view : vsHash.values()) { if (!viewHashSet.contains(view.getName())) { viewHashSet.add(view.getName()); list.add(view); } } } } return list; }
From source file:edu.ku.brc.specify.config.SpecifyAppContextMgr.java
/** * @return all unique views (does NOT return any internal views) */// w w w.j av a2s. c o m public List<ViewIFace> getAllViews() { Hashtable<String, ViewIFace> viewHash = new Hashtable<String, ViewIFace>(); for (SpAppResourceDir appResDir : spAppResourceList) { //if (appResDir.getDiscipline() != null && appResDir.getDiscipline() == discipline) { for (ViewSetIFace vs : getViewSetList(appResDir)) { Hashtable<String, ViewIFace> vsHash = vs.getViews(); for (ViewIFace view : vsHash.values()) { //log.debug(view.isInternal()+" "+view.getName()); if (!view.isInternal() && viewHash.get(view.getName()) == null) { viewHash.put(view.getName(), view); } } } } } return new Vector<ViewIFace>(viewHash.values()); }
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;//from w w w . j a v a2s. 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:org.LexGrid.LexBIG.Impl.dataAccess.SQLImplementedMethods.java
public static Entity buildCodedEntry(String internalCodingSchemeName, String internalVersionString, String code, String namespace, LocalNameList restrictToProperties, PropertyType[] restrictToPropertyTypes) throws UnexpectedInternalError, MissingResourceException { try {/*www . jav a 2 s . c o m*/ Entity concept = new Entity(); concept.setEntityCode(code); SQLInterface si = ResourceManager.instance().getSQLInterface(internalCodingSchemeName, internalVersionString); //if the namespace is null (and its 2009 model), set it to the default (which is //equal to the codingSchemeName. //This shouldn't ever happen -- all classes that call this method should provide //a namespace. if (si.supports2009Model() && StringUtils.isBlank(namespace)) { namespace = internalCodingSchemeName; } ArrayList<Definition> definitions = new ArrayList<Definition>(); ArrayList<Presentation> presentations = new ArrayList<Presentation>(); ArrayList<Property> properties = new ArrayList<Property>(); ArrayList<Comment> comments = new ArrayList<Comment>(); ArrayList<PropertyLink> links = new ArrayList<PropertyLink>(); PreparedStatement getEntityCode = null; PreparedStatement getEntityType = null; PreparedStatement getEntityProperties = null; PreparedStatement getPropertyLinks = null; try { StringBuffer buildEntity = new StringBuffer(); buildEntity .append("Select * " + " from " + si.getTableName(SQLTableConstants.ENTITY) + " {AS} t1 "); if (si.supports2009Model()) { buildEntity.append("left join " + si.getTableName(SQLTableConstants.ENTRY_STATE) + " {AS} t2 " + "on t1." + SQLTableConstants.TBLCOL_ENTRYSTATEID + " = t2." + SQLTableConstants.TBLCOL_ENTRYSTATEID); } buildEntity.append(" where " + si.getSQLTableConstants().codingSchemeNameOrId + " = ? AND " + si.getSQLTableConstants().entityCodeOrId + " = ?"); if (si.supports2009Model()) { buildEntity.append(" AND " + SQLTableConstants.TBLCOL_ENTITYCODENAMESPACE + " = ?"); } getEntityCode = si.modifyAndCheckOutPreparedStatement(buildEntity.toString()); getEntityCode.setString(1, internalCodingSchemeName); getEntityCode.setString(2, code); if (si.supports2009Model()) { getEntityCode.setString(3, namespace); } ResultSet results = getEntityCode.executeQuery(); // one and only one result if (results.next()) { concept.setIsDefined( DBUtility.getBooleanFromResultSet(results, SQLTableConstants.TBLCOL_ISDEFINED)); concept.setIsAnonymous( DBUtility.getBooleanFromResultSet(results, SQLTableConstants.TBLCOL_ISANONYMOUS)); concept.setIsActive( DBUtility.getBooleanFromResultSet(results, SQLTableConstants.TBLCOL_ISACTIVE)); if (!si.supports2009Model()) { concept.setStatus(results.getString(SQLTableConstants.TBLCOL_CONCEPTSTATUS)); } else { concept.setEntityCodeNamespace(namespace); } EntityDescription ed = new EntityDescription(); ed.setContent(results.getString(SQLTableConstants.TBLCOL_ENTITYDESCRIPTION)); concept.setEntityDescription(ed); if (si.supports2009Model()) { String owner = results.getString(SQLTableConstants.TBLCOL_OWNER); String status = results.getString(SQLTableConstants.TBLCOL_STATUS); Timestamp effectiveDate = results.getTimestamp(SQLTableConstants.TBLCOL_EFFECTIVEDATE); Timestamp expirationDate = results.getTimestamp(SQLTableConstants.TBLCOL_EXPIRATIONDATE); String revisionId = results.getString(SQLTableConstants.TBLCOL_REVISIONID); String prevRevisionId = results.getString(SQLTableConstants.TBLCOL_PREVREVISIONID); String changeType = results.getString(SQLTableConstants.TBLCOL_CHANGETYPE); String relativeOrder = results.getString(SQLTableConstants.TBLCOL_RELATIVEORDER); EntryState es = new EntryState(); if (!StringUtils.isBlank(changeType)) { es.setChangeType(org.LexGrid.versions.types.ChangeType.valueOf(changeType)); } es.setContainingRevision(revisionId); es.setPrevRevision(prevRevisionId); es.setRelativeOrder(computeRelativeOrder(relativeOrder)); concept.setEntryState(es); if (owner != null) { concept.setOwner(owner); } concept.setStatus(status); concept.setEffectiveDate(effectiveDate); concept.setExpirationDate(expirationDate); } } results.close(); si.checkInPreparedStatement(getEntityCode); if (si.supports2009Model()) { getEntityType = si.checkOutPreparedStatement( "Select * " + " from " + si.getTableName(SQLTableConstants.ENTITY_TYPE) + " where " + si.getSQLTableConstants().codingSchemeNameOrId + " = ? AND " + si.getSQLTableConstants().entityCodeOrId + " = ? AND " + SQLTableConstants.TBLCOL_ENTITYCODENAMESPACE + " = ?"); getEntityType.setString(1, internalCodingSchemeName); getEntityType.setString(2, code); getEntityType.setString(3, namespace); results = getEntityType.executeQuery(); while (results.next()) { concept.addEntityType(results.getString(SQLTableConstants.TBLCOL_ENTITYTYPE)); } results.close(); si.checkInPreparedStatement(getEntityType); } else { concept.addEntityType(SQLTableConstants.ENTITYTYPE_CONCEPT); } // populate the property links String addWhereSegment = (!si.supports2009Model() ? (si.getSQLTableConstants().entityType + " = '" + SQLTableConstants.ENTITYTYPE_CONCEPT + "' and ") : ""); getPropertyLinks = si .checkOutPreparedStatement("Select " + SQLTableConstants.TBLCOL_SOURCEPROPERTYID + ", " + SQLTableConstants.TBLCOL_LINK + ", " + SQLTableConstants.TBLCOL_TARGETPROPERTYID + " from " + si.getTableName(SQLTableConstants.ENTITY_PROPERTY_LINKS) + " where " + addWhereSegment + si.getSQLTableConstants().entityCodeOrEntityId + " = ? and " + si.getSQLTableConstants().codingSchemeNameOrId + " = ?"); getPropertyLinks.setString(1, code); getPropertyLinks.setString(2, internalCodingSchemeName); results = getPropertyLinks.executeQuery(); while (results.next()) { String sourcePropertyId = results.getString(SQLTableConstants.TBLCOL_SOURCEPROPERTYID); String link = results.getString(SQLTableConstants.TBLCOL_LINK); String targetPropertyId = results.getString(SQLTableConstants.TBLCOL_TARGETPROPERTYID); PropertyLink pl = new PropertyLink(); pl.setPropertyLink(link); pl.setSourceProperty(sourcePropertyId); pl.setTargetProperty(targetPropertyId); links.add(pl); } results.close(); si.checkInPreparedStatement(getPropertyLinks); // codedEntry.setModVersion(null); StringBuffer propertyQuery = new StringBuffer(); // I'm constructing a left join query to get the property // results I need from 3 (or 2 in 1.5 table version) different // tables at once, rather than doing a query on each. propertyQuery.append("SELECT a." + SQLTableConstants.TBLCOL_PROPERTYID + ", a." + SQLTableConstants.TBLCOL_PROPERTYNAME + ", a." + SQLTableConstants.TBLCOL_LANGUAGE + ", a." + SQLTableConstants.TBLCOL_FORMAT + ", a." + SQLTableConstants.TBLCOL_ISPREFERRED + ", a." + SQLTableConstants.TBLCOL_DEGREEOFFIDELITY + ", a." + SQLTableConstants.TBLCOL_MATCHIFNOCONTEXT + ", a." + SQLTableConstants.TBLCOL_REPRESENTATIONALFORM + ", a." + SQLTableConstants.TBLCOL_PROPERTYVALUE + ", a." + SQLTableConstants.TBLCOL_PROPERTYTYPE + (si.supports2009Model() ? (", a." + SQLTableConstants.TBLCOL_ENTRYSTATEID) : "") + (si.supports2009Model() ? ", es.*" : "") + ", b." + SQLTableConstants.TBLCOL_TYPENAME + ", b." + SQLTableConstants.TBLCOL_ATTRIBUTEVALUE + ", b." + SQLTableConstants.TBLCOL_VAL1 + ", b." + SQLTableConstants.TBLCOL_VAL2); propertyQuery.append(" FROM "); String codingSchemeName = si.getSQLTableConstants().codingSchemeNameOrId; String concptCode = si.getSQLTableConstants().entityCodeOrEntityId; propertyQuery.append(si.getTableName(SQLTableConstants.ENTITY_PROPERTY) + " {AS} a "); propertyQuery.append( " left join " + si.getTableName(SQLTableConstants.ENTITY_PROPERTY_MULTI_ATTRIBUTES)); propertyQuery.append(" {AS} b on a." + codingSchemeName + " = b." + codingSchemeName + " and a." + concptCode + " = b." + concptCode + " and a." + SQLTableConstants.TBLCOL_PROPERTYID + " = b." + SQLTableConstants.TBLCOL_PROPERTYID); if (si.supports2009Model()) { propertyQuery .append(" left join " + si.getTableName(SQLTableConstants.ENTRY_STATE) + " {AS} es "); propertyQuery.append("on a." + SQLTableConstants.TBLCOL_ENTRYSTATEID); propertyQuery.append(" = es." + SQLTableConstants.TBLCOL_ENTRYSTATEID); } propertyQuery.append(" where a." + concptCode + " = ? " + "and a." + codingSchemeName + " = ?"); if (si.supports2009Model()) { propertyQuery.append(" and a." + SQLTableConstants.TBLCOL_ENTITYCODENAMESPACE + " = ?"); } if (restrictToProperties != null && restrictToProperties.getEntryCount() > 0) { propertyQuery.append(" AND ("); for (int i = 0; i < restrictToProperties.getEntryCount(); i++) { propertyQuery.append(" " + si.getSQLTableConstants().propertyOrPropertyName + " = ? "); if (i + 1 < restrictToProperties.getEntryCount()) { propertyQuery.append(" OR "); } } propertyQuery.append(")"); } if (restrictToPropertyTypes != null && restrictToPropertyTypes.length > 0) { propertyQuery.append(" AND ("); for (int i = 0; i < restrictToPropertyTypes.length; i++) { propertyQuery.append(" " + SQLTableConstants.TBLCOL_PROPERTYTYPE + " = ? "); if (i + 1 < restrictToPropertyTypes.length) { propertyQuery.append(" OR "); } } propertyQuery.append(")"); } getEntityProperties = si.modifyAndCheckOutPreparedStatement(propertyQuery.toString()); int i = 1; getEntityProperties.setString(i++, code); getEntityProperties.setString(i++, internalCodingSchemeName); if (si.supports2009Model()) { getEntityProperties.setString(i++, namespace); } if (restrictToProperties != null && restrictToProperties.getEntryCount() > 0) { for (int j = 0; j < restrictToProperties.getEntryCount(); j++) { getEntityProperties.setString(i++, restrictToProperties.getEntry(j)); } } if (restrictToPropertyTypes != null && restrictToPropertyTypes.length > 0) { for (int j = 0; j < restrictToPropertyTypes.length; j++) { String pts = RestrictionImplementations.mapPropertyType(restrictToPropertyTypes[j]); getEntityProperties.setString(i++, pts); } } results = getEntityProperties.executeQuery(); // store the property from the last row org.LexGrid.commonTypes.Property newProperty = null; // all of the fields that come from the Property table String propertyType, property, propertyValue, language, presentationFormat, degreeOfFidelity, propertyId, representationalForm; Boolean matchIfNoContext, isPreferred; // holders for attributes, qualifiers Hashtable<String, Source> sources = null; HashSet<String> usageContexts = null; Hashtable<String, PropertyQualifier> propertyQualifiers = null; // As I process the result rows, I will get back duplicates of // the property information // if the property has more than one qualifer and/or source , // etc. while (results.next()) { propertyId = results.getString(SQLTableConstants.TBLCOL_PROPERTYID); if (newProperty == null || !propertyId.equals(newProperty.getPropertyId())) { // not equal means we have started a new property property = results.getString(si.getSQLTableConstants().propertyOrPropertyName); propertyType = results.getString(SQLTableConstants.TBLCOL_PROPERTYTYPE); propertyValue = results.getString(SQLTableConstants.TBLCOL_PROPERTYVALUE); language = results.getString(SQLTableConstants.TBLCOL_LANGUAGE); presentationFormat = results .getString(si.getSQLTableConstants().formatOrPresentationFormat); degreeOfFidelity = results.getString(SQLTableConstants.TBLCOL_DEGREEOFFIDELITY); representationalForm = results.getString(SQLTableConstants.TBLCOL_REPRESENTATIONALFORM); matchIfNoContext = DBUtility.getBooleanFromResultSet(results, SQLTableConstants.TBLCOL_MATCHIFNOCONTEXT); isPreferred = DBUtility.getBooleanFromResultSet(results, SQLTableConstants.TBLCOL_ISPREFERRED); // add all of the collected sources, usage contexts, and // qualifiers to // the previous property if (newProperty != null) { newProperty.setSource(sources.values().toArray(new Source[sources.size()])); newProperty.setUsageContext(usageContexts.toArray(new String[usageContexts.size()])); if (!propertyQualifiers.isEmpty()) newProperty.setPropertyQualifier(propertyQualifiers.values() .toArray(new PropertyQualifier[propertyQualifiers.size()])); } // we are starting a new property, so clear out the old // holders. sources = new Hashtable<String, Source>(); usageContexts = new HashSet<String>(); propertyQualifiers = new Hashtable<String, PropertyQualifier>(); // process the property portion of the result if (propertyType.equals(SQLTableConstants.TBLCOLVAL_DEFINITION)) { Definition def = new Definition(); def.setIsPreferred(isPreferred); def.setLanguage(language); def.setPropertyName(property); def.setPropertyId(propertyId); Text text = new Text(); text.setContent(propertyValue); text.setDataType(presentationFormat); def.setValue(text); definitions.add(def); newProperty = def; } else if (propertyType.equals(SQLTableConstants.TBLCOLVAL_PRESENTATION)) { Presentation presentation = new Presentation(); presentation.setIsPreferred(isPreferred); presentation.setLanguage(language); presentation.setPropertyName(property); presentation.setPropertyId(propertyId); Text text = new Text(); text.setContent(propertyValue); text.setDataType(presentationFormat); presentation.setValue(text); presentation.setDegreeOfFidelity(degreeOfFidelity); presentation.setMatchIfNoContext(matchIfNoContext); presentation.setRepresentationalForm(representationalForm); presentations.add(presentation); newProperty = presentation; } else if (propertyType.equals(SQLTableConstants.TBLCOLVAL_COMMENT)) { Comment comment = new Comment(); comment.setLanguage(language); comment.setPropertyName(property); comment.setPropertyId(propertyId); Text text = new Text(); text.setContent(propertyValue); text.setDataType(presentationFormat); comment.setValue(text); comments.add(comment); newProperty = comment; } else { Property theProperty = new Property(); theProperty.setLanguage(language); theProperty.setPropertyName(property); theProperty.setPropertyId(propertyId); Text text = new Text(); text.setContent(propertyValue); text.setDataType(presentationFormat); theProperty.setValue(text); properties.add(theProperty); newProperty = theProperty; } newProperty.setPropertyType(propertyType); if (si.supports2009Model()) { String owner = results.getString(SQLTableConstants.TBLCOL_OWNER); String status = results.getString(SQLTableConstants.TBLCOL_STATUS); Timestamp effectiveDate = results.getTimestamp(SQLTableConstants.TBLCOL_EFFECTIVEDATE); Timestamp expirationDate = results .getTimestamp(SQLTableConstants.TBLCOL_EXPIRATIONDATE); String revisionId = results.getString(SQLTableConstants.TBLCOL_REVISIONID); String prevRevisionId = results.getString(SQLTableConstants.TBLCOL_PREVREVISIONID); String changeType = results.getString(SQLTableConstants.TBLCOL_CHANGETYPE); String relativeOrder = results.getString(SQLTableConstants.TBLCOL_RELATIVEORDER); if (revisionId != null) { EntryState es = new EntryState(); if (!StringUtils.isBlank(changeType)) { es.setChangeType(org.LexGrid.versions.types.ChangeType.valueOf(changeType)); } es.setContainingRevision(revisionId); es.setPrevRevision(prevRevisionId); es.setRelativeOrder(computeRelativeOrder(relativeOrder)); newProperty.setEntryState(es); } if (owner != null) { newProperty.setOwner(owner); } if (status != null) newProperty.setStatus(status); if (effectiveDate != null) newProperty.setEffectiveDate(effectiveDate); if (expirationDate != null) newProperty.setExpirationDate(expirationDate); } } String type = null; String value = null; String val1 = null; String val2 = null; // collect values from the multiAttributes table type = results.getString(SQLTableConstants.TBLCOL_TYPENAME); value = results.getString(SQLTableConstants.TBLCOL_ATTRIBUTEVALUE); val1 = results.getString(SQLTableConstants.TBLCOL_VAL1); if (StringUtils.isBlank(val1)) val1 = null; val2 = results.getString(SQLTableConstants.TBLCOL_VAL2); if (StringUtils.isBlank(val2)) val2 = null; // hashsets to remove dupes (table doesn't allow dupes, but // left join will create some) if (type != null) { if (type.equalsIgnoreCase(SQLTableConstants.TBLCOLVAL_SOURCE)) { if (!sources.containsKey(createUniqueKeyForSource(value, val1))) { Source s = new Source(); s.setContent(value); s.setRole(val2); s.setSubRef(val1); sources.put(createUniqueKeyForSource(value, val1), s); } } else if (type.equalsIgnoreCase(SQLTableConstants.TBLCOLVAL_USAGECONTEXT)) { usageContexts.add(value); } else if (type.equalsIgnoreCase(SQLTableConstants.TBLCOLVAL_QUALIFIER)) { // nulls are a side affect of left join if (!propertyQualifiers.containsKey(val1 + ":" + value)) { PropertyQualifier pq = new PropertyQualifier(); Text txt = new Text(); txt.setContent(val1); pq.setValue(txt); pq.setPropertyQualifierName(value); propertyQualifiers.put(val1 + ":" + value, pq); } } else { getLogger().warn("There is invalid data in the 'typeName' column in the table " + si.getTableName(SQLTableConstants.ENTITY_PROPERTY_MULTI_ATTRIBUTES) + " for the concept code: " + code + " propertyId: " + propertyId + " codingSchemeName: " + internalCodingSchemeName); } } } // add all of the collected sources, usage contexts, and // qualifiers to // the previous property before exiting ... if (newProperty != null) { newProperty.setSource(sources.values().toArray(new Source[sources.size()])); newProperty.setUsageContext(usageContexts.toArray(new String[usageContexts.size()])); if (!propertyQualifiers.isEmpty()) newProperty.setPropertyQualifier(propertyQualifiers.values() .toArray(new PropertyQualifier[propertyQualifiers.size()])); } results.close(); } finally { si.checkInPreparedStatement(getEntityCode); si.checkInPreparedStatement(getEntityProperties); si.checkInPreparedStatement(getPropertyLinks); } concept.setComment(comments.toArray(new Comment[comments.size()])); concept.setDefinition(definitions.toArray(new Definition[definitions.size()])); concept.setPropertyLink(links.toArray(new PropertyLink[links.size()])); concept.setPresentation(presentations.toArray(new Presentation[presentations.size()])); concept.setProperty(properties.toArray(new Property[properties.size()])); return concept; } catch (MissingResourceException e) { throw e; } catch (Exception e) { throw new UnexpectedInternalError("There was an unexpected internal error.", e); } }
From source file:org.talend.designer.core.ui.editor.process.Process.java
private void loadRejectConnector(Hashtable<String, Node> nodesHashtable) { Collection<Node> nodes = nodesHashtable.values(); for (Node node : nodes) { ValidationRulesUtil.updateRejectMetatable(node, null); }/*from www .j a v a 2 s.c om*/ }
From source file:org.lexevs.dao.database.sqlimplementedmethods.SQLImplementedMethodsDao.java
/** * Builds the coded entry./*www . j av a2 s .co m*/ * * @param internalCodingSchemeName the internal coding scheme name * @param internalVersionString the internal version string * @param code the code * @param namespace the namespace * @param restrictToProperties the restrict to properties * @param restrictToPropertyTypes the restrict to property types * * @return the entity * * @throws UnexpectedInternalError the unexpected internal error * @throws MissingResourceException the missing resource exception */ public Entity buildCodedEntry(String internalCodingSchemeName, String internalVersionString, String code, String namespace, LocalNameList restrictToProperties, PropertyType[] restrictToPropertyTypes) throws UnexpectedInternalError, MissingResourceException { try { Entity concept = new Entity(); concept.setEntityCode(code); SQLInterface si = resourceManager.getSQLInterface(internalCodingSchemeName, internalVersionString); //if the namespace is null (and its 2009 model), set it to the default (which is //equal to the codingSchemeName. //This shouldn't ever happen -- all classes that call this method should provide //a namespace. if (si.supports2009Model() && StringUtils.isBlank(namespace)) { namespace = internalCodingSchemeName; } ArrayList<Definition> definitions = new ArrayList<Definition>(); ArrayList<Presentation> presentations = new ArrayList<Presentation>(); ArrayList<Property> properties = new ArrayList<Property>(); ArrayList<Comment> comments = new ArrayList<Comment>(); ArrayList<PropertyLink> links = new ArrayList<PropertyLink>(); PreparedStatement getEntityCode = null; PreparedStatement getEntityType = null; PreparedStatement getEntityProperties = null; PreparedStatement getPropertyLinks = null; try { StringBuffer buildEntity = new StringBuffer(); buildEntity .append("Select * " + " from " + si.getTableName(SQLTableConstants.ENTITY) + " {AS} t1 "); if (si.supports2009Model()) { buildEntity.append("left join " + si.getTableName(SQLTableConstants.ENTRY_STATE) + " {AS} t2 " + "on t1." + SQLTableConstants.TBLCOL_ENTRYSTATEID + " = t2." + SQLTableConstants.TBLCOL_ENTRYSTATEID); } buildEntity.append(" where " + si.getSQLTableConstants().codingSchemeNameOrId + " = ? AND " + si.getSQLTableConstants().entityCodeOrId + " = ?"); if (si.supports2009Model()) { buildEntity.append(" AND " + SQLTableConstants.TBLCOL_ENTITYCODENAMESPACE + " = ?"); } getEntityCode = si.modifyAndCheckOutPreparedStatement(buildEntity.toString()); getEntityCode.setString(1, internalCodingSchemeName); getEntityCode.setString(2, code); if (si.supports2009Model()) { getEntityCode.setString(3, namespace); } ResultSet results = getEntityCode.executeQuery(); // one and only one result if (results.next()) { concept.setIsDefined( DBUtility.getBooleanFromResultSet(results, SQLTableConstants.TBLCOL_ISDEFINED)); concept.setIsAnonymous( DBUtility.getBooleanFromResultSet(results, SQLTableConstants.TBLCOL_ISANONYMOUS)); concept.setIsActive( DBUtility.getBooleanFromResultSet(results, SQLTableConstants.TBLCOL_ISACTIVE)); if (!si.supports2009Model()) { concept.setStatus(results.getString(SQLTableConstants.TBLCOL_CONCEPTSTATUS)); } else { concept.setEntityCodeNamespace(namespace); } EntityDescription ed = new EntityDescription(); ed.setContent(results.getString(SQLTableConstants.TBLCOL_ENTITYDESCRIPTION)); concept.setEntityDescription(ed); if (si.supports2009Model()) { String owner = results.getString(SQLTableConstants.TBLCOL_OWNER); String status = results.getString(SQLTableConstants.TBLCOL_STATUS); Timestamp effectiveDate = results.getTimestamp(SQLTableConstants.TBLCOL_EFFECTIVEDATE); Timestamp expirationDate = results.getTimestamp(SQLTableConstants.TBLCOL_EXPIRATIONDATE); String revisionId = results.getString(SQLTableConstants.TBLCOL_REVISIONID); String prevRevisionId = results.getString(SQLTableConstants.TBLCOL_PREVREVISIONID); String changeType = results.getString(SQLTableConstants.TBLCOL_CHANGETYPE); String relativeOrder = results.getString(SQLTableConstants.TBLCOL_RELATIVEORDER); EntryState es = new EntryState(); if (!StringUtils.isBlank(changeType)) { es.setChangeType(org.LexGrid.versions.types.ChangeType.valueOf(changeType)); } es.setContainingRevision(revisionId); es.setPrevRevision(prevRevisionId); es.setRelativeOrder(computeRelativeOrder(relativeOrder)); concept.setEntryState(es); if (owner != null) { concept.setOwner(owner); } concept.setStatus(status); concept.setEffectiveDate(effectiveDate); concept.setExpirationDate(expirationDate); } } results.close(); si.checkInPreparedStatement(getEntityCode); if (si.supports2009Model()) { getEntityType = si.checkOutPreparedStatement( "Select * " + " from " + si.getTableName(SQLTableConstants.ENTITY_TYPE) + " where " + si.getSQLTableConstants().codingSchemeNameOrId + " = ? AND " + si.getSQLTableConstants().entityCodeOrId + " = ? AND " + SQLTableConstants.TBLCOL_ENTITYCODENAMESPACE + " = ?"); getEntityType.setString(1, internalCodingSchemeName); getEntityType.setString(2, code); getEntityType.setString(3, namespace); results = getEntityType.executeQuery(); while (results.next()) { concept.addEntityType(results.getString(SQLTableConstants.TBLCOL_ENTITYTYPE)); } results.close(); si.checkInPreparedStatement(getEntityType); } else { concept.addEntityType(SQLTableConstants.ENTITYTYPE_CONCEPT); } // populate the property links String addWhereSegment = (!si.supports2009Model() ? (si.getSQLTableConstants().entityType + " = '" + SQLTableConstants.ENTITYTYPE_CONCEPT + "' and ") : ""); getPropertyLinks = si .checkOutPreparedStatement("Select " + SQLTableConstants.TBLCOL_SOURCEPROPERTYID + ", " + SQLTableConstants.TBLCOL_LINK + ", " + SQLTableConstants.TBLCOL_TARGETPROPERTYID + " from " + si.getTableName(SQLTableConstants.ENTITY_PROPERTY_LINKS) + " where " + addWhereSegment + si.getSQLTableConstants().entityCodeOrEntityId + " = ? and " + si.getSQLTableConstants().codingSchemeNameOrId + " = ?"); getPropertyLinks.setString(1, code); getPropertyLinks.setString(2, internalCodingSchemeName); results = getPropertyLinks.executeQuery(); while (results.next()) { String sourcePropertyId = results.getString(SQLTableConstants.TBLCOL_SOURCEPROPERTYID); String link = results.getString(SQLTableConstants.TBLCOL_LINK); String targetPropertyId = results.getString(SQLTableConstants.TBLCOL_TARGETPROPERTYID); PropertyLink pl = new PropertyLink(); pl.setPropertyLink(link); pl.setSourceProperty(sourcePropertyId); pl.setTargetProperty(targetPropertyId); links.add(pl); } results.close(); si.checkInPreparedStatement(getPropertyLinks); // codedEntry.setModVersion(null); StringBuffer propertyQuery = new StringBuffer(); // I'm constructing a left join query to get the property // results I need from 3 (or 2 in 1.5 table version) different // tables at once, rather than doing a query on each. propertyQuery.append("SELECT a." + SQLTableConstants.TBLCOL_PROPERTYID + ", a." + SQLTableConstants.TBLCOL_PROPERTYNAME + ", a." + SQLTableConstants.TBLCOL_LANGUAGE + ", a." + SQLTableConstants.TBLCOL_FORMAT + ", a." + SQLTableConstants.TBLCOL_ISPREFERRED + ", a." + SQLTableConstants.TBLCOL_DEGREEOFFIDELITY + ", a." + SQLTableConstants.TBLCOL_MATCHIFNOCONTEXT + ", a." + SQLTableConstants.TBLCOL_REPRESENTATIONALFORM + ", a." + SQLTableConstants.TBLCOL_PROPERTYVALUE + ", a." + SQLTableConstants.TBLCOL_PROPERTYTYPE + (si.supports2009Model() ? (", a." + SQLTableConstants.TBLCOL_ENTRYSTATEID) : "") + (si.supports2009Model() ? ", es.*" : "") + ", b." + SQLTableConstants.TBLCOL_TYPENAME + ", b." + SQLTableConstants.TBLCOL_ATTRIBUTEVALUE + ", b." + SQLTableConstants.TBLCOL_VAL1 + ", b." + SQLTableConstants.TBLCOL_VAL2); propertyQuery.append(" FROM "); String codingSchemeName = si.getSQLTableConstants().codingSchemeNameOrId; String concptCode = si.getSQLTableConstants().entityCodeOrEntityId; propertyQuery.append(si.getTableName(SQLTableConstants.ENTITY_PROPERTY) + " {AS} a "); propertyQuery.append( " left join " + si.getTableName(SQLTableConstants.ENTITY_PROPERTY_MULTI_ATTRIBUTES)); propertyQuery.append(" {AS} b on a." + codingSchemeName + " = b." + codingSchemeName + " and a." + concptCode + " = b." + concptCode + " and a." + SQLTableConstants.TBLCOL_PROPERTYID + " = b." + SQLTableConstants.TBLCOL_PROPERTYID); if (si.supports2009Model()) { propertyQuery .append(" left join " + si.getTableName(SQLTableConstants.ENTRY_STATE) + " {AS} es "); propertyQuery.append("on a." + SQLTableConstants.TBLCOL_ENTRYSTATEID); propertyQuery.append(" = es." + SQLTableConstants.TBLCOL_ENTRYSTATEID); } propertyQuery.append(" where a." + concptCode + " = ? " + "and a." + codingSchemeName + " = ?"); if (si.supports2009Model()) { propertyQuery.append(" and a." + SQLTableConstants.TBLCOL_ENTITYCODENAMESPACE + " = ?"); } if (restrictToProperties != null && restrictToProperties.getEntryCount() > 0) { propertyQuery.append(" AND ("); for (int i = 0; i < restrictToProperties.getEntryCount(); i++) { propertyQuery.append(" " + si.getSQLTableConstants().propertyOrPropertyName + " = ? "); if (i + 1 < restrictToProperties.getEntryCount()) { propertyQuery.append(" OR "); } } propertyQuery.append(")"); } if (restrictToPropertyTypes != null && restrictToPropertyTypes.length > 0) { propertyQuery.append(" AND ("); for (int i = 0; i < restrictToPropertyTypes.length; i++) { propertyQuery.append(" " + SQLTableConstants.TBLCOL_PROPERTYTYPE + " = ? "); if (i + 1 < restrictToPropertyTypes.length) { propertyQuery.append(" OR "); } } propertyQuery.append(")"); } getEntityProperties = si.modifyAndCheckOutPreparedStatement(propertyQuery.toString()); int i = 1; getEntityProperties.setString(i++, code); getEntityProperties.setString(i++, internalCodingSchemeName); if (si.supports2009Model()) { getEntityProperties.setString(i++, namespace); } if (restrictToProperties != null && restrictToProperties.getEntryCount() > 0) { for (int j = 0; j < restrictToProperties.getEntryCount(); j++) { getEntityProperties.setString(i++, restrictToProperties.getEntry(j)); } } if (restrictToPropertyTypes != null && restrictToPropertyTypes.length > 0) { for (int j = 0; j < restrictToPropertyTypes.length; j++) { String pts = DaoUtility.propertyTypeToStringMap.get(restrictToPropertyTypes[j]); getEntityProperties.setString(i++, pts); } } results = getEntityProperties.executeQuery(); // store the property from the last row org.LexGrid.commonTypes.Property newProperty = null; // all of the fields that come from the Property table String propertyType, property, propertyValue, language, presentationFormat, degreeOfFidelity, propertyId, representationalForm; Boolean matchIfNoContext, isPreferred; // holders for attributes, qualifiers Hashtable<String, Source> sources = null; HashSet<String> usageContexts = null; Hashtable<String, PropertyQualifier> propertyQualifiers = null; // As I process the result rows, I will get back duplicates of // the property information // if the property has more than one qualifer and/or source , // etc. while (results.next()) { propertyId = results.getString(SQLTableConstants.TBLCOL_PROPERTYID); if (newProperty == null || !propertyId.equals(newProperty.getPropertyId())) { // not equal means we have started a new property property = results.getString(si.getSQLTableConstants().propertyOrPropertyName); propertyType = results.getString(SQLTableConstants.TBLCOL_PROPERTYTYPE); propertyValue = results.getString(SQLTableConstants.TBLCOL_PROPERTYVALUE); language = results.getString(SQLTableConstants.TBLCOL_LANGUAGE); presentationFormat = results .getString(si.getSQLTableConstants().formatOrPresentationFormat); degreeOfFidelity = results.getString(SQLTableConstants.TBLCOL_DEGREEOFFIDELITY); representationalForm = results.getString(SQLTableConstants.TBLCOL_REPRESENTATIONALFORM); matchIfNoContext = DBUtility.getBooleanFromResultSet(results, SQLTableConstants.TBLCOL_MATCHIFNOCONTEXT); isPreferred = DBUtility.getBooleanFromResultSet(results, SQLTableConstants.TBLCOL_ISPREFERRED); // add all of the collected sources, usage contexts, and // qualifiers to // the previous property if (newProperty != null) { newProperty.setSource(sources.values().toArray(new Source[sources.size()])); newProperty.setUsageContext(usageContexts.toArray(new String[usageContexts.size()])); if (!propertyQualifiers.isEmpty()) newProperty.setPropertyQualifier(propertyQualifiers.values() .toArray(new PropertyQualifier[propertyQualifiers.size()])); } // we are starting a new property, so clear out the old // holders. sources = new Hashtable<String, Source>(); usageContexts = new HashSet<String>(); propertyQualifiers = new Hashtable<String, PropertyQualifier>(); // process the property portion of the result if (propertyType.equals(SQLTableConstants.TBLCOLVAL_DEFINITION)) { Definition def = new Definition(); def.setIsPreferred(isPreferred); def.setLanguage(language); def.setPropertyName(property); def.setPropertyId(propertyId); Text text = new Text(); text.setContent(propertyValue); text.setDataType(presentationFormat); def.setValue(text); definitions.add(def); newProperty = def; } else if (propertyType.equals(SQLTableConstants.TBLCOLVAL_PRESENTATION)) { Presentation presentation = new Presentation(); presentation.setIsPreferred(isPreferred); presentation.setLanguage(language); presentation.setPropertyName(property); presentation.setPropertyId(propertyId); Text text = new Text(); text.setContent(propertyValue); text.setDataType(presentationFormat); presentation.setValue(text); presentation.setDegreeOfFidelity(degreeOfFidelity); presentation.setMatchIfNoContext(matchIfNoContext); presentation.setRepresentationalForm(representationalForm); presentations.add(presentation); newProperty = presentation; } else if (propertyType.equals(SQLTableConstants.TBLCOLVAL_COMMENT)) { Comment comment = new Comment(); comment.setLanguage(language); comment.setPropertyName(property); comment.setPropertyId(propertyId); Text text = new Text(); text.setContent(propertyValue); text.setDataType(presentationFormat); comment.setValue(text); comments.add(comment); newProperty = comment; } else { Property theProperty = new Property(); theProperty.setLanguage(language); theProperty.setPropertyName(property); theProperty.setPropertyId(propertyId); Text text = new Text(); text.setContent(propertyValue); text.setDataType(presentationFormat); theProperty.setValue(text); properties.add(theProperty); newProperty = theProperty; } newProperty.setPropertyType(propertyType); if (si.supports2009Model()) { String owner = results.getString(SQLTableConstants.TBLCOL_OWNER); String status = results.getString(SQLTableConstants.TBLCOL_STATUS); Timestamp effectiveDate = results.getTimestamp(SQLTableConstants.TBLCOL_EFFECTIVEDATE); Timestamp expirationDate = results .getTimestamp(SQLTableConstants.TBLCOL_EXPIRATIONDATE); String revisionId = results.getString(SQLTableConstants.TBLCOL_REVISIONID); String prevRevisionId = results.getString(SQLTableConstants.TBLCOL_PREVREVISIONID); String changeType = results.getString(SQLTableConstants.TBLCOL_CHANGETYPE); String relativeOrder = results.getString(SQLTableConstants.TBLCOL_RELATIVEORDER); if (revisionId != null) { EntryState es = new EntryState(); if (!StringUtils.isBlank(changeType)) { es.setChangeType(org.LexGrid.versions.types.ChangeType.valueOf(changeType)); } es.setContainingRevision(revisionId); es.setPrevRevision(prevRevisionId); es.setRelativeOrder(computeRelativeOrder(relativeOrder)); newProperty.setEntryState(es); } if (owner != null) { newProperty.setOwner(owner); } if (status != null) newProperty.setStatus(status); if (effectiveDate != null) newProperty.setEffectiveDate(effectiveDate); if (expirationDate != null) newProperty.setExpirationDate(expirationDate); } } String type = null; String value = null; String val1 = null; String val2 = null; // collect values from the multiAttributes table type = results.getString(SQLTableConstants.TBLCOL_TYPENAME); value = results.getString(SQLTableConstants.TBLCOL_ATTRIBUTEVALUE); val1 = results.getString(SQLTableConstants.TBLCOL_VAL1); if (StringUtils.isBlank(val1)) val1 = null; val2 = results.getString(SQLTableConstants.TBLCOL_VAL2); if (StringUtils.isBlank(val2)) val2 = null; // hashsets to remove dupes (table doesn't allow dupes, but // left join will create some) if (type != null) { if (type.equalsIgnoreCase(SQLTableConstants.TBLCOLVAL_SOURCE)) { if (!sources.containsKey(createUniqueKeyForSource(value, val1))) { Source s = new Source(); s.setContent(value); s.setRole(val2); s.setSubRef(val1); sources.put(createUniqueKeyForSource(value, val1), s); } } else if (type.equalsIgnoreCase(SQLTableConstants.TBLCOLVAL_USAGECONTEXT)) { usageContexts.add(value); } else if (type.equalsIgnoreCase(SQLTableConstants.TBLCOLVAL_QUALIFIER)) { // nulls are a side affect of left join if (!propertyQualifiers.containsKey(val1 + ":" + value)) { PropertyQualifier pq = new PropertyQualifier(); Text txt = new Text(); txt.setContent(val1); pq.setValue(txt); pq.setPropertyQualifierName(value); propertyQualifiers.put(val1 + ":" + value, pq); } } else { getLogger().warn("There is invalid data in the 'typeName' column in the table " + si.getTableName(SQLTableConstants.ENTITY_PROPERTY_MULTI_ATTRIBUTES) + " for the concept code: " + code + " propertyId: " + propertyId + " codingSchemeName: " + internalCodingSchemeName); } } } // add all of the collected sources, usage contexts, and // qualifiers to // the previous property before exiting ... if (newProperty != null) { newProperty.setSource(sources.values().toArray(new Source[sources.size()])); newProperty.setUsageContext(usageContexts.toArray(new String[usageContexts.size()])); if (!propertyQualifiers.isEmpty()) newProperty.setPropertyQualifier(propertyQualifiers.values() .toArray(new PropertyQualifier[propertyQualifiers.size()])); } results.close(); } finally { si.checkInPreparedStatement(getEntityCode); si.checkInPreparedStatement(getEntityProperties); si.checkInPreparedStatement(getPropertyLinks); } concept.setComment(comments.toArray(new Comment[comments.size()])); concept.setDefinition(definitions.toArray(new Definition[definitions.size()])); concept.setPropertyLink(links.toArray(new PropertyLink[links.size()])); concept.setPresentation(presentations.toArray(new Presentation[presentations.size()])); concept.setProperty(properties.toArray(new Property[properties.size()])); return concept; } catch (MissingResourceException e) { throw e; } catch (Exception e) { throw new UnexpectedInternalError("There was an unexpected internal error.", e); } }
From source file:edu.ku.brc.specify.web.SpecifyExplorer.java
/** * @param response//from www .j a v a 2 s .c o m */ protected void generateDateChart(final HttpServletRequest request, final HttpServletResponse response, final String sql, final String title, final String x_AxisTitle, final String y_AxisTitle) { String type = request.getParameter("type"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy"); Hashtable<String, NameId> alphaHash = new Hashtable<String, NameId>(); Vector<NameId> alphaList = null; Connection connection = null; Statement stmt = null; ResultSet rs = null; try { connection = DBConnection.getInstance().createConnection(); stmt = connection.createStatement(); rs = stmt.executeQuery(sql); while (rs.next()) { Date date = rs.getDate(1); String dateStr = sdf.format(date); int year = Integer.parseInt(dateStr); int decade = (year / 10) * 10; dateStr = Integer.toString(decade); NameId nis = alphaHash.get(dateStr); if (nis == null) { nis = new NameId(dateStr, 0); alphaHash.put(dateStr, nis); } nis.add(); } } catch (Exception ex) { ex.printStackTrace(); } finally { try { if (rs != null) { rs.close(); } if (stmt != null) { stmt.close(); } if (connection != null) { connection.close(); } } catch (Exception e) { e.printStackTrace(); } } alphaList = new Vector<NameId>(alphaHash.values()); Collections.sort(alphaList); createChart(response, type, alphaList, title, x_AxisTitle, y_AxisTitle); }
From source file:edu.ku.brc.specify.web.SpecifyExplorer.java
/** * @param response/* w w w .j ava2s. c o m*/ */ protected void generateCEChartOld(final HttpServletRequest request, final HttpServletResponse response) { String type = request.getParameter("type"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy"); Hashtable<String, NameId> alphaHash = new Hashtable<String, NameId>(); Vector<NameId> alphaList = null; Connection connection = null; Statement stmt = null; ResultSet rs = null; try { connection = DBConnection.getInstance().createConnection(); stmt = connection.createStatement(); rs = stmt.executeQuery("select startDate from collectingevent where startDate is not null"); while (rs.next()) { Date date = rs.getDate(1); String dateStr = sdf.format(date); int year = Integer.parseInt(dateStr); int decade = (year / 10) * 10; dateStr = Integer.toString(decade); NameId nis = alphaHash.get(dateStr); if (nis == null) { nis = new NameId(dateStr, 0); alphaHash.put(dateStr, nis); } nis.add(); } } catch (Exception ex) { ex.printStackTrace(); } finally { try { if (rs != null) { rs.close(); } if (stmt != null) { stmt.close(); } if (connection != null) { connection.close(); } } catch (Exception e) { e.printStackTrace(); } } alphaList = new Vector<NameId>(alphaHash.values()); Collections.sort(alphaList); createChart(response, type, alphaList, "Collecting Events By Decade", "Decades", "Number of Collecting Events"); }
From source file:org.unitime.timetable.util.SessionRollForward.java
public void rollCurriculaForward(ActionMessages errors, RollForwardSessionForm rollForwardSessionForm) { Session toSession = Session.getSessionById(rollForwardSessionForm.getSessionToRollForwardTo()); Session fromSession = Session.getSessionById(rollForwardSessionForm.getSessionToRollCurriculaForwardFrom()); org.hibernate.Session hibSession = CurriculumDAO.getInstance().getSession(); // roll forward academic areas, if needed Hashtable<String, AcademicArea> areas = new Hashtable<String, AcademicArea>(); for (AcademicArea area : AcademicAreaDAO.getInstance().findBySession(hibSession, toSession.getUniqueId())) { areas.put(area.getAcademicAreaAbbreviation(), area); }/*from ww w . ja v a2 s . com*/ if (areas.isEmpty()) { for (AcademicArea area : AcademicAreaDAO.getInstance().findBySession(hibSession, fromSession.getUniqueId())) { AcademicArea newArea = (AcademicArea) area.clone(); newArea.setSession(toSession); newArea.setPosMajors(new HashSet<PosMajor>()); newArea.setPosMinors(new HashSet<PosMinor>()); hibSession.save(newArea); areas.put(newArea.getAcademicAreaAbbreviation(), newArea); } } // roll forward academic classifications, if needed Hashtable<String, AcademicClassification> classifications = new Hashtable<String, AcademicClassification>(); for (AcademicClassification clasf : AcademicClassificationDAO.getInstance().findBySession(hibSession, toSession.getUniqueId())) { classifications.put(clasf.getCode(), clasf); } if (classifications.isEmpty()) { for (AcademicClassification clasf : AcademicClassificationDAO.getInstance().findBySession(hibSession, fromSession.getUniqueId())) { AcademicClassification newClasf = (AcademicClassification) clasf.clone(); newClasf.setSession(toSession); hibSession.save(newClasf); classifications.put(newClasf.getCode(), newClasf); } } // roll forward majors, if needed Hashtable<String, Hashtable<String, PosMajor>> majors = new Hashtable<String, Hashtable<String, PosMajor>>(); for (PosMajor major : PosMajorDAO.getInstance().findBySession(hibSession, toSession.getUniqueId())) { for (AcademicArea area : major.getAcademicAreas()) { Hashtable<String, PosMajor> code2major = majors.get(area.getAcademicAreaAbbreviation()); if (code2major == null) { code2major = new Hashtable<String, PosMajor>(); majors.put(area.getAcademicAreaAbbreviation(), code2major); } code2major.put(major.getCode(), major); } } if (majors.isEmpty()) { for (PosMajor major : PosMajorDAO.getInstance().findBySession(hibSession, fromSession.getUniqueId())) { Set<AcademicArea> newAreas = new HashSet<AcademicArea>(); for (AcademicArea area : major.getAcademicAreas()) { AcademicArea newArea = areas.get(area.getAcademicAreaAbbreviation()); if (newArea != null) newAreas.add(newArea); } if (newAreas.isEmpty()) continue; PosMajor newMajor = (PosMajor) major.clone(); newMajor.setSession(toSession); newMajor.setAcademicAreas(newAreas); for (AcademicArea newArea : newAreas) { newArea.getPosMajors().add(newMajor); Hashtable<String, PosMajor> code2major = majors.get(newArea.getAcademicAreaAbbreviation()); if (code2major == null) { code2major = new Hashtable<String, PosMajor>(); majors.put(newArea.getAcademicAreaAbbreviation(), code2major); } code2major.put(newMajor.getCode(), newMajor); } hibSession.save(newMajor); } } // roll forward minors, if needed Hashtable<String, Hashtable<String, PosMinor>> minors = new Hashtable<String, Hashtable<String, PosMinor>>(); for (PosMinor minor : PosMinorDAO.getInstance().findBySession(hibSession, toSession.getUniqueId())) { for (AcademicArea area : minor.getAcademicAreas()) { Hashtable<String, PosMinor> code2minor = minors.get(area.getAcademicAreaAbbreviation()); if (code2minor == null) { code2minor = new Hashtable<String, PosMinor>(); minors.put(area.getAcademicAreaAbbreviation(), code2minor); } code2minor.put(minor.getCode(), minor); } } if (minors.isEmpty()) { for (PosMinor minor : PosMinorDAO.getInstance().findBySession(hibSession, fromSession.getUniqueId())) { Set<AcademicArea> newAreas = new HashSet<AcademicArea>(); for (AcademicArea area : minor.getAcademicAreas()) { AcademicArea newArea = areas.get(area.getAcademicAreaAbbreviation()); if (newArea != null) newAreas.add(newArea); } if (newAreas.isEmpty()) continue; PosMinor newMinor = (PosMinor) minor.clone(); newMinor.setSession(toSession); newMinor.setAcademicAreas(newAreas); for (AcademicArea newArea : newAreas) { newArea.getPosMinors().add(newMinor); Hashtable<String, PosMinor> code2minor = minors.get(newArea.getAcademicAreaAbbreviation()); if (code2minor == null) { code2minor = new Hashtable<String, PosMinor>(); minors.put(newArea.getAcademicAreaAbbreviation(), code2minor); } code2minor.put(newMinor.getCode(), newMinor); } hibSession.save(newMinor); } } // course translation table Hashtable<Long, CourseOffering> courses = new Hashtable<Long, CourseOffering>(); for (CourseOffering course : (List<CourseOffering>) hibSession .createQuery( "select co from CourseOffering co " + "where co.uniqueIdRolledForwardFrom is not null and " + "co.subjectArea.session.uniqueId = :sessionId") .setLong("sessionId", toSession.getUniqueId()).list()) { courses.put(course.getUniqueIdRolledForwardFrom(), course); } // cleanup all curricula for (Iterator<Curriculum> i = hibSession .createQuery("select c from Curriculum c where c.department.session=:sessionId") .setLong("sessionId", toSession.getUniqueId()).list().iterator(); i.hasNext();) { hibSession.delete(i.next()); } hibSession.flush(); // roll forward curricula Department tempDept = null; curricula: for (Curriculum curriculum : (List<Curriculum>) hibSession .createQuery("select c from Curriculum c where c.department.session=:sessionId") .setLong("sessionId", fromSession.getUniqueId()).list()) { Curriculum newCurriculum = new Curriculum(); newCurriculum.setAbbv(curriculum.getAbbv()); newCurriculum.setName(curriculum.getName()); newCurriculum.setMultipleMajors(curriculum.isMultipleMajors()); AcademicArea area = areas.get(curriculum.getAcademicArea().getAcademicAreaAbbreviation()); if (area == null) continue; newCurriculum.setAcademicArea(area); Department dept = curriculum.getDepartment().findSameDepartmentInSession(toSession); if (dept == null) { if (tempDept == null) { tempDept = Department.findByDeptCode("TEMP", toSession.getUniqueId()); if (tempDept == null) { tempDept = new Department(); tempDept.setAbbreviation("TEMP"); tempDept.setAllowReqRoom(new Boolean(false)); tempDept.setAllowReqTime(new Boolean(false)); tempDept.setAllowReqDistribution(new Boolean(false)); tempDept.setDeptCode("TEMP"); tempDept.setExternalManager(new Boolean(false)); tempDept.setExternalUniqueId(null); tempDept.setName("Temp Department For New Curricula"); tempDept.setSession(toSession); tempDept.setDistributionPrefPriority(new Integer(0)); tempDept.setInheritInstructorPreferences(true); tempDept.setAllowEvents(false); tempDept.setAllowStudentScheduling(false); toSession.addTodepartments(tempDept); hibSession.save(tempDept); } } dept = tempDept; } newCurriculum.setDepartment(dept); newCurriculum.setMajors(new HashSet<PosMajor>()); Hashtable<String, PosMajor> code2major = majors.get(area.getAcademicAreaAbbreviation()); for (PosMajor major : curriculum.getMajors()) { PosMajor newMajor = (code2major == null ? null : code2major.get(major.getCode())); if (newMajor == null) continue curricula; newCurriculum.getMajors().add(newMajor); } newCurriculum.setClassifications(new HashSet<CurriculumClassification>()); Hashtable<Long, CurriculumCourseGroup> createdGroups = new Hashtable<Long, CurriculumCourseGroup>(); for (CurriculumClassification clasf : curriculum.getClassifications()) { CurriculumClassification newClasf = new CurriculumClassification(); AcademicClassification f = classifications.get(clasf.getAcademicClassification().getCode()); if (f == null) continue; newClasf.setAcademicClassification(f); newClasf.setCurriculum(newCurriculum); newClasf.setName(clasf.getName()); newClasf.setNrStudents(clasf.getNrStudents()); newClasf.setOrd(clasf.getOrd()); newClasf.setCourses(new HashSet<CurriculumCourse>()); newCurriculum.getClassifications().add(newClasf); for (CurriculumCourse course : clasf.getCourses()) { CurriculumCourse newCourse = new CurriculumCourse(); newCourse.setOrd(course.getOrd()); newCourse.setPercShare(course.getPercShare()); CourseOffering co = courses.get(course.getCourse().getUniqueId()); if (co == null) continue; newCourse.setCourse(co); newCourse.setClassification(newClasf); newClasf.getCourses().add(newCourse); newCourse.setGroups(new HashSet<CurriculumCourseGroup>()); for (CurriculumCourseGroup group : course.getGroups()) { CurriculumCourseGroup newGroup = createdGroups.get(group.getUniqueId()); if (newGroup == null) { newGroup = new CurriculumCourseGroup(); newGroup.setColor(group.getColor()); newGroup.setName(group.getName()); newGroup.setType(group.getType()); newGroup.setCurriculum(newCurriculum); createdGroups.put(group.getUniqueId(), newGroup); } newCourse.getGroups().add(newGroup); } } } hibSession.save(newCurriculum); for (CurriculumCourseGroup g : createdGroups.values()) hibSession.saveOrUpdate(g); } // roll forward projection rules (if empty) if (hibSession.createQuery( "select r from CurriculumProjectionRule r where r.academicArea.session.uniqueId = :sessionId") .setLong("sessionId", toSession.getUniqueId()).list().isEmpty()) { rules: for (CurriculumProjectionRule rule : (List<CurriculumProjectionRule>) hibSession .createQuery("select r from CurriculumProjectionRule r " + "where r.academicArea.session.uniqueId = :sessionId") .setLong("sessionId", fromSession.getUniqueId()).list()) { CurriculumProjectionRule newRule = new CurriculumProjectionRule(); AcademicArea area = areas.get(rule.getAcademicArea().getAcademicAreaAbbreviation()); if (area == null) continue; newRule.setAcademicArea(area); AcademicClassification clasf = classifications.get(rule.getAcademicClassification().getCode()); if (clasf == null) continue; newRule.setAcademicClassification(clasf); if (rule.getMajor() != null) { Hashtable<String, PosMajor> code2major = majors.get(area.getAcademicAreaAbbreviation()); PosMajor major = (code2major == null ? null : code2major.get(rule.getMajor().getCode())); if (major == null) continue rules; newRule.setMajor(major); } newRule.setProjection(rule.getProjection()); hibSession.save(newRule); } } hibSession.flush(); hibSession.clear(); }