public boolean isRubrique() { boolean rubrique; try { String name = m_column.getName(); DbSMSStereotype stereotype = m_column.getUmlStereotype(); rubrique = (name == null) ? false : name.endsWith(RUBRIQUE_SUFFIX); rubrique |= (stereotype == null) ? false : RUBRIQUE_STEREOTYPE.equals(stereotype.getName()); } catch (DbException ex) { rubrique = false; } return rubrique; }
public String getFormat() { String format; try { DbORTypeClassifier type = m_column.getType(); String typename = (type == null) ? UNDEFINED : type.getName(); String len = m_column.getLengthNbDecimal(); len = (len == null) ? "" : len; format = typename + len; } catch (DbException ex) { format = "???"; } // end if return format; }
// find, if any, the column of 'table' whose name is 'columnName' private DbORColumn findColumn(DbORTable table, String columnName) throws DbException { DbORColumn namedColumn = null; DbRelationN relN = table.getComponents(); DbEnumeration enu = relN.elements(DbORColumn.metaClass); while (enu.hasMoreElements()) { DbORColumn c = (DbORColumn) enu.nextElement(); if (columnName.equals(c.getName())) { namedColumn = c; break; } } // end while enu.close(); return namedColumn; }
public String getDescription() { String description; try { description = m_column.getDescription(); } catch (DbException ex) { description = null; } return description; }
public String getNullable() { String nullable; try { nullable = m_column.isNull() ? YES : NO; } catch (DbException ex) { nullable = "???"; } // end if return nullable; }
DbColumnWrapper getSuperColumn(DbProjectWrapper project) throws DbException { DbORColumn sc = (DbORColumn) m_column.getSuperCopy(); // physical super-column // if no physical super-column, look for logical super-column if (sc == null) { sc = getLogicalSuperColumn(); } // if neither physical nor logical super-column, return null if (sc == null) { return null; } DbORTable t = (DbORTable) sc.getCompositeOfType(DbORTable.metaClass); DbORDataModel dm = (DbORDataModel) t.getCompositeOfType(DbORDataModel.metaClass); DbDataModelWrapper dataModel = project.getDataModel(dm); DbTableWrapper table = dataModel.getTable(t); DbColumnWrapper superColumn = new DbColumnWrapper(table, sc); return superColumn; }
@Override public String toString() { String name; try { name = m_parent.getName() + "." + m_column.getName(); } catch (DbException ex) { name = super.toString(); } // end try return name; }
public String getUdfValue(String udfName) { String value; try { Object o = m_column.getUDF(udfName); value = (o == null) ? "" : o.toString(); } catch (DbException ex) { value = "???"; } return value; }
public String getName() { String tableName = m_parent.getName(); String columnName; try { columnName = m_column.getName(); } catch (DbException ex) { columnName = "???"; } String name = tableName + "." + columnName; return name; }
private DbORColumn getLogicalSuperColumn() throws DbException { DbORColumn logicalSuperColumn = null; DbORTable t1 = (DbORTable) m_column.getCompositeOfType(DbORTable.metaClass); boolean rubrique = isRubrique(t1); if (rubrique) { DbORTable t2 = findParentTable(t1); DbORTable t0 = (t2 == null) ? null : (DbORTable) t2.getSuperCopy(); logicalSuperColumn = (t0 == null) ? null : findColumn(t0, t1.getName()); } return logicalSuperColumn; }
public String getModelName() throws DbException { DbORDataModel model = (DbORDataModel) m_column.getCompositeOfType(DbORDataModel.metaClass); String name = model.getName(); return name; }
private void propagateCommonItemValues(DbORCommonItem item, int options) throws DbException { // get mandatory properties DbORTypeClassifier type = item.getType(); Integer len = item.getLength(); Integer dec = item.getNbDecimal(); boolean isNull = item.getNull(); // get optional properties String name = item.getName(); String physicalName = item.getPhysicalName(); String alias = item.getAlias(); String desc = item.getDescription(); DbSMSStereotype stereotype = item.getUmlStereotype(); // for each column DbRelationN relN = item.getColumns(); DbEnumeration dbEnum = relN.elements(DbORColumn.metaClass); while (dbEnum.hasMoreElements()) { m_changesmade = true; // set mandatory properties DbORColumn column = (DbORColumn) dbEnum.nextElement(); column.setType(type); column.setLength(len); column.setNbDecimal(dec); column.setNull(Boolean.valueOf(isNull)); // set optional properties if ((options & NAME) != 0) { column.setName(name); } if ((options & PHYSICAL_NAME) != 0) { column.setPhysicalName(physicalName); } if ((options & ALIAS) != 0) { column.setAlias(alias); } if ((options & DESCRIPTION) != 0) { column.setDescription(desc); } if ((options & STEREOTYPE) != 0) { column.setUmlStereotype(stereotype); } } // end while dbEnum.close(); // get object properties DbOOAdt ooType = item.getOoType(); String typeUse = item.getTypeUse(); OOTypeUseStyle style = item.getTypeUseStyle(); JVVisibility visib = (JVVisibility) item.getVisibility(); boolean isStatic = item.isStatic(); boolean isFinal = item.isFinal(); boolean isTransient = item.isTransient(); boolean isVolatile = item.isVolatile(); // for each field relN = item.getFields(); dbEnum = relN.elements(DbJVDataMember.metaClass); while (dbEnum.hasMoreElements()) { m_changesmade = true; // set mandatory oo properties DbJVDataMember field = (DbJVDataMember) dbEnum.nextElement(); field.setType(ooType); field.setTypeUse(typeUse); field.setTypeUseStyle(style); field.setVisibility(visib); field.setStatic(Boolean.valueOf(isStatic)); field.setFinal(new Boolean(isFinal)); field.setTransient(new Boolean(isTransient)); field.setVolatile(new Boolean(isVolatile)); // set optional properties if ((options & NAME) != 0) { field.setName(name); } if ((options & ALIAS) != 0) { field.setAlias(alias); } if ((options & DESCRIPTION) != 0) { field.setDescription(desc); } if ((options & STEREOTYPE) != 0) { field.setUmlStereotype(stereotype); } } // end while dbEnum.close(); } // end propagateCommonItemValues()
private void propagateCommonItemValues( DbORCommonItem item, DbObject concept, boolean isObjectOriented, int options) throws DbException { m_changesmade = true; // get mandatory properties DbORTypeClassifier type = item.getType(); Integer len = item.getLength(); Integer dec = item.getNbDecimal(); boolean isNull = item.getNull(); // get optional properties String name = item.getName(); String physicalName = item.getPhysicalName(); String alias = item.getAlias(); String desc = item.getDescription(); DbSMSStereotype stereotype = item.getUmlStereotype(); if (!isObjectOriented) { DbORColumn column = (DbORColumn) concept; column.setType(type); column.setLength(len); column.setNbDecimal(dec); column.setNull(Boolean.valueOf(isNull)); // set optional properties if ((options & NAME) != 0) { column.setName(name); } if ((options & PHYSICAL_NAME) != 0) { column.setPhysicalName(physicalName); } if ((options & ALIAS) != 0) { column.setAlias(alias); } if ((options & DESCRIPTION) != 0) { column.setDescription(desc); } if ((options & STEREOTYPE) != 0) { column.setUmlStereotype(stereotype); } } // end while else { // get object properties DbOOAdt ooType = item.getOoType(); String typeUse = item.getTypeUse(); OOTypeUseStyle style = item.getTypeUseStyle(); JVVisibility visib = (JVVisibility) item.getVisibility(); boolean isStatic = item.isStatic(); boolean isFinal = item.isFinal(); boolean isTransient = item.isTransient(); boolean isVolatile = item.isVolatile(); // set mandatory oo properties DbJVDataMember field = (DbJVDataMember) concept; field.setType(ooType); field.setTypeUse(typeUse); field.setTypeUseStyle(style); field.setVisibility(visib); field.setStatic(Boolean.valueOf(isStatic)); field.setFinal(new Boolean(isFinal)); field.setTransient(new Boolean(isTransient)); field.setVolatile(new Boolean(isVolatile)); // set optional properties if ((options & NAME) != 0) { field.setName(name); } if ((options & ALIAS) != 0) { field.setAlias(alias); } if ((options & DESCRIPTION) != 0) { field.setDescription(desc); } if ((options & STEREOTYPE) != 0) { field.setUmlStereotype(stereotype); } } // end while }
// // PRIVATE METHODS // private void propagateCommonItems() { g_options = getOptions(); m_changesmade = false; try { m_semObjs[0].getDb().beginWriteTrans(m_title); int nb = m_semObjs.length; for (int i = 0; i < nb; i++) { DbObject semObj = m_semObjs[i]; if (semObj instanceof DbORCommonItemModel) { DbORCommonItemModel model = (DbORCommonItemModel) semObj; propagateCommonItemValues(model, g_options); } else if (semObj instanceof DbORCommonItem) { DbORCommonItem item = (DbORCommonItem) semObj; propagateCommonItemValues(item, g_options); } // end if else if (semObj instanceof DbORDataModel) { DbObject tableOrView = null; DbEnumeration orTableEnum = semObj.getComponents().elements(DbORAbsTable.metaClass); while (orTableEnum.hasMoreElements()) { tableOrView = orTableEnum.nextElement(); DbEnumeration orColumnEnum = tableOrView.getComponents().elements(DbORColumn.metaClass); DbORCommonItem item = null; while (orColumnEnum.hasMoreElements()) { DbORColumn parm = (DbORColumn) orColumnEnum.nextElement(); item = (DbORCommonItem) parm.get(DbORColumn.fCommonItem); if (item != null) propagateCommonItemValues(item, parm, false, g_options); } orColumnEnum.close(); } orTableEnum.close(); } else if (semObj instanceof DbORColumn) { DbORCommonItem item = (DbORCommonItem) semObj.get(DbORColumn.fCommonItem); if (item != null) propagateCommonItemValues(item, semObj, false, g_options); } else if (semObj instanceof DbORAbsTable) { DbEnumeration orColumnEnum = semObj.getComponents().elements(DbORColumn.metaClass); DbORCommonItem item = null; while (orColumnEnum.hasMoreElements()) { DbORColumn parm = (DbORColumn) orColumnEnum.nextElement(); item = (DbORCommonItem) parm.get(DbORColumn.fCommonItem); if (item != null) propagateCommonItemValues(item, parm, false, g_options); } orColumnEnum.close(); } else if (semObj instanceof DbOOClassModel) { DbObject tableOrView = null; DbEnumeration orTableEnum = semObj.getComponents().elements(DbOOClass.metaClass); while (orTableEnum.hasMoreElements()) { tableOrView = orTableEnum.nextElement(); DbEnumeration orColumnEnum = tableOrView.getComponents().elements(DbJVDataMember.metaClass); DbORCommonItem item = null; while (orColumnEnum.hasMoreElements()) { DbJVDataMember parm = (DbJVDataMember) orColumnEnum.nextElement(); item = (DbORCommonItem) parm.get(DbJVDataMember.fCommonItem); if (item != null) propagateCommonItemValues(item, parm, true, g_options); } orColumnEnum.close(); } orTableEnum.close(); } else if (semObj instanceof DbOOClass) { DbEnumeration orColumnEnum = semObj.getComponents().elements(DbJVDataMember.metaClass); DbORCommonItem item = null; while (orColumnEnum.hasMoreElements()) { DbJVDataMember parm = (DbJVDataMember) orColumnEnum.nextElement(); item = (DbORCommonItem) parm.get(DbJVDataMember.fCommonItem); if (item != null) propagateCommonItemValues(item, parm, true, g_options); } orColumnEnum.close(); } else if (semObj instanceof DbJVDataMember) { DbORCommonItem item = (DbORCommonItem) semObj.get(DbJVDataMember.fCommonItem); if (item != null) propagateCommonItemValues(item, semObj, true, g_options); } } // end for m_semObjs[0].getDb().commitTrans(); if (m_changesmade == false) JOptionPane.showMessageDialog( this, LocaleMgr.screen.getString("NoCommonItemToPropagate"), ApplicationContext.getApplicationName(), JOptionPane.INFORMATION_MESSAGE); } catch (Exception e) { org.modelsphere.jack.util.ExceptionHandler.processUncatchedException( ApplicationContext.getDefaultMainFrame(), e); } } // end propagateCommonItems()