fireVetoableChange(PROP_ASSOCIATED_COLUMNS, null, null); if (!getAssociatedColumns().remove(columnName)) I18NHelper.getMessage(getMessages(), "mapping.element.element_not_removed", // NOI18N columnName)); firePropertyChange(PROP_ASSOCIATED_COLUMNS, null, null);
final RelationshipElement getRelationshipElement () { return ((MappingClassElementImpl)getDeclaringClass()). getPersistenceElement().getRelationship(getName()); }
/** Get the update action for this relationship element. * @return the update action, one of * {@link RelationshipElement#NONE_ACTION}, * {@link RelationshipElement#NULLIFY_ACTION}, * {@link RelationshipElement#RESTRICT_ACTION}, * {@link RelationshipElement#CASCADE_ACTION}, or * {@link RelationshipElement#AGGREGATE_ACTION} */ public int getUpdateAction () { return getRelationshipElement().getUpdateAction(); }
/** Returns the list of associated columns (ColumnPairElements) to * which this mapping field is mapped. This is used for join tables. * This method should only be used by the runtime. * @return the columns mapped by this mapping field * @see MappingFieldElement#getColumns */ public ArrayList getAssociatedColumnObjects () { if (_associatedColumnObjects == null) { _associatedColumnObjects = MappingClassElementImpl. toColumnObjects(getDeclaringClass().getDatabaseRoot(), getAssociatedColumns()); } return _associatedColumnObjects; }
ArrayList columnObjects = mre.getColumnObjects(); int colCount = ((columnObjects != null) ? columnObjects.size() : 0); println(tabs+1, "associatedColumns = " + mre.getAssociatedColumns()); //NOI18N ArrayList associatedColumnObjects = mre.getAssociatedColumnObjects(); colCount = ((associatedColumnObjects != null) ? associatedColumnObjects.size() : 0);
/** Adds a column to the list of columns mapped by this mapping * relationship. This method overrides the one in MappingFieldElement to * check that the argument is a ColumnPairElement. * @param column column element to be added to the mapping * @exception ModelException if impossible */ public void addColumn (DBMemberElement column) throws ModelException { if (column instanceof ColumnPairElement) { if (!getAssociatedColumns().isEmpty()) { throw new ModelException(I18NHelper.getMessage(getMessages(), "mapping.column.associated_columns_defined", // NOI18N NameUtil.getRelativeMemberName( column.getName().getFullName()))); } super.addColumn(column); } else { throw new ModelException(I18NHelper.getMessage(getMessages(), "mapping.column.column_invalid", // NOI18N NameUtil.getRelativeMemberName( column.getName().getFullName()))); } }
/** * Create and add mapping relationship with column pairs to mapping class. * The column pair for mappingRelationship is same order as the column * pair from foreign key. It is used for 1-1 or 1-M relationship * It is column pair between local table and foreign table * @param relationName relationship name for the declaring mapping class * @param mappingClass mapping class that holds the relationship * @param foreign key which hold column pair for the relationship * @throws ModelException */ private void addMappingRelationship(String relationName, MappingClassElement declaringClass, ForeignKeyElement fkey) throws ModelException { MappingRelationshipElement impl = new MappingRelationshipElementImpl( relationName, declaringClass); ColumnPairElement [] pairs = fkey.getColumnPairs(); for (int i = 0; i < pairs.length; i++) { ColumnPairElement pair = pairs[i]; impl.addColumn(pair); } declaringClass.addField(impl); }
ArrayList columnObjects = mre.getColumnObjects(); int colCount = ((columnObjects != null) ? columnObjects.size() : 0); println(tabs+1, "associatedColumns = " + mre.getAssociatedColumns()); //NOI18N ArrayList associatedColumnObjects = mre.getAssociatedColumnObjects(); colCount = ((associatedColumnObjects != null) ? associatedColumnObjects.size() : 0);
/** Returns the list of associated columns (ColumnPairElements) to * which this mapping field is mapped. This is used for join tables. * This method should only be used by the runtime. * @return the columns mapped by this mapping field * @see MappingFieldElement#getColumns */ public ArrayList getAssociatedColumnObjects () { if (_associatedColumnObjects == null) { _associatedColumnObjects = MappingClassElementImpl. toColumnObjects(getDeclaringClass().getDatabaseRoot(), getAssociatedColumns()); } return _associatedColumnObjects; }
/** Adds a column to the list of columns mapped by this mapping * relationship. This method overrides the one in MappingFieldElement to * check that the argument is a ColumnPairElement. * @param column column element to be added to the mapping * @exception ModelException if impossible */ public void addColumn (DBMemberElement column) throws ModelException { if (column instanceof ColumnPairElement) { if (!getAssociatedColumns().isEmpty()) { throw new ModelException(I18NHelper.getMessage(getMessages(), "mapping.column.associated_columns_defined", // NOI18N NameUtil.getRelativeMemberName( column.getName().getFullName()))); } super.addColumn(column); } else { throw new ModelException(I18NHelper.getMessage(getMessages(), "mapping.column.column_invalid", // NOI18N NameUtil.getRelativeMemberName( column.getName().getFullName()))); } }
/** * Create and add MappingRelationship with associated column pairs * for join table. The column pair for mappingRelationship is same * order as the column pair from foreign key. * It is for column pairs between the join table and the foreign table * @param relationName a String for relation name * @param mappingClass mapping class that holds the relationship * @param fkeyForeign holding column pair information for the relationship * @throws ModelException */ private void addAssocMappingRelationship(String relationName, MappingClassElement declaringClass, ForeignKeyElement fkeyForeign) throws ModelException { MappingRelationshipElement impl = (MappingRelationshipElement) declaringClass.getField( relationName); if (null == impl) { impl = new MappingRelationshipElementImpl( relationName, declaringClass); declaringClass.addField(impl); } // Add column pair for join table and foreign table ColumnPairElement [] pairs = fkeyForeign.getColumnPairs(); for (int i = 0; i < pairs.length; i++) { ColumnPairElement pair = pairs[i]; impl.addAssociatedColumn(pair); } }
fireVetoableChange(PROP_ASSOCIATED_COLUMNS, null, null); if (!getAssociatedColumns().remove(columnName)) I18NHelper.getMessage(getMessages(), "mapping.element.element_not_removed", // NOI18N columnName)); firePropertyChange(PROP_ASSOCIATED_COLUMNS, null, null);
/** Get the delete action for this relationship element. * @return the delete action, one of * {@link RelationshipElement#NONE_ACTION}, * {@link RelationshipElement#NULLIFY_ACTION}, * {@link RelationshipElement#RESTRICT_ACTION}, * {@link RelationshipElement#CASCADE_ACTION}, or * {@link RelationshipElement#AGGREGATE_ACTION} */ public int getDeleteAction () { return getRelationshipElement().getDeleteAction(); }
final RelationshipElement getRelationshipElement () { return ((MappingClassElementImpl)getDeclaringClass()). getPersistenceElement().getRelationship(getName()); }
impl = new MappingRelationshipElementImpl(relationName, declaringClass); declaringClass.addField(impl);
ArrayList columns = getAssociatedColumns(); String columnName = NameUtil.getRelativeMemberName( column.getName().getFullName()); fireVetoableChange(PROP_ASSOCIATED_COLUMNS, null, null); columns.add(columnName); firePropertyChange(PROP_ASSOCIATED_COLUMNS, null, null); throw new ModelException(I18NHelper.getMessage(getMessages(), "mapping.column.column_defined", columnName)); // NOI18N throw new ModelException(I18NHelper.getMessage(getMessages(), "mapping.element.null_argument")); // NOI18N
/** Get the lower cardinality bound for this relationship element. * @return the lower cardinality bound */ public int getLowerBound () { return getRelationshipElement().getLowerBound(); }
new RelationshipElementImpl(fieldName), pce); MappingRelationshipElement mre = new MappingRelationshipElementImpl(fieldName, mce);
ArrayList columns = getAssociatedColumns(); String columnName = NameUtil.getRelativeMemberName( column.getName().getFullName()); fireVetoableChange(PROP_ASSOCIATED_COLUMNS, null, null); columns.add(columnName); firePropertyChange(PROP_ASSOCIATED_COLUMNS, null, null); throw new ModelException(I18NHelper.getMessage(getMessages(), "mapping.column.column_defined", columnName)); // NOI18N throw new ModelException(I18NHelper.getMessage(getMessages(), "mapping.element.null_argument")); // NOI18N
/** Get the delete action for this relationship element. * @return the delete action, one of * {@link RelationshipElement#NONE_ACTION}, * {@link RelationshipElement#NULLIFY_ACTION}, * {@link RelationshipElement#RESTRICT_ACTION}, * {@link RelationshipElement#CASCADE_ACTION}, or * {@link RelationshipElement#AGGREGATE_ACTION} */ public int getDeleteAction () { return getRelationshipElement().getDeleteAction(); }