private void doUpdate(Session hSession) throws HibernateException { MetadataTable tUpdates = getMetadataTable(MetadataTable.UPDATE); Iterator i = mClasses.values().iterator(); while (i.hasNext()) { MClass clazz = (MClass) i.next(); Set hUpdates = new HashSet(); List updates = tUpdates.getDataRows(clazz.getPath()); if (updates != null) { Iterator j = updates.iterator(); while (j.hasNext()) { Metadata md = (Metadata) j.next(); Update hUpdate = new Update(); hUpdate.setMClass(clazz); hUpdate.setUpdateName(md.getAttribute("UpdateName")); hUpdate.setDescription(md.getAttribute("Description")); hUpdate.setKeyField(md.getAttribute("KeyField")); hUpdate.updateLevel(); hSession.save(hUpdate); hUpdates.add(hUpdate); mUpdates.put(hUpdate.getPath(), hUpdate); } } clazz.setUpdates(hUpdates); hSession.saveOrUpdate(clazz); } }
public void doUpdateType(Session hSession) throws HibernateException { MetadataTable tUpdateTypes = getMetadataTable(MetadataTable.UPDATE_TYPE); Iterator i = mUpdates.values().iterator(); while (i.hasNext()) { Update update = (Update) i.next(); Set hUpdateTypes = new HashSet(); List updateTypes = tUpdateTypes.getDataRows(update.getPath()); if (updateTypes != null) { Iterator j = updateTypes.iterator(); while (j.hasNext()) { Metadata md = (Metadata) j.next(); UpdateType updateType = new UpdateType(); updateType.setUpdate(update); String level = update.getLevel(); String systemName = md.getAttribute("SystemName"); String tablePath = level + ":" + systemName; Table table = (Table) mTables.get(tablePath); updateType.setTable(table); // Hack to get around metadata bug if (table == null) { LOG.error("null table for path: " + tablePath); System.exit(1); } updateType.setSequence(Integer.parseInt(md.getAttribute("Sequence"))); String joinedAttributes = md.getAttribute("Attributes"); String attributes[] = StringUtils.split(joinedAttributes, ","); Set attributeSet = new HashSet(); for (int c = 0; c < attributes.length; c++) { attributeSet.add(UpdateTypeAttributeEnum.fromInt(Integer.parseInt(attributes[c]))); } updateType.setAttributes(attributeSet); updateType.setDefault(md.getAttribute("Default")); String valExp[] = StringUtils.split(md.getAttribute("ValidationExpressionID"), ","); Set valExpSet = new HashSet(); String resourcePath = update.getMClass().getResource().getPath(); for (int c = 0; c < valExp.length; c++) { String vePath = resourcePath + ":" + valExp[c]; ValidationExpression ve = (ValidationExpression) mValidationExpressions.get(vePath); valExpSet.add(ve); } updateType.setValidationExpressions(valExpSet); String updateHelpPath = resourcePath + ":" + md.getAttribute("UpdateHelpID"); updateType.setUpdateHelp((UpdateHelp) mUpdateHelps.get(updateHelpPath)); String vlPath = resourcePath + ":" + md.getAttribute("ValdiationLookupName"); updateType.setValidationLookup((ValidationLookup) mValidationLookups.get(vlPath)); String vePath = resourcePath + ":" + md.getAttribute("ValdationExternalName"); updateType.setValidationExternal((ValidationExternal) mValidationExternals.get(vePath)); hSession.save(updateType); hUpdateTypes.add(updateType); } } update.setUpdateTypes(hUpdateTypes); hSession.saveOrUpdate(update); } }