Class MappingClassElementImpl

    • Constructor Detail

      • MappingClassElementImpl

        public MappingClassElementImpl()
        Create new MappingClassElementImpl with no corresponding persistence element or name. This constructor should only be used for cloning and archiving.
      • MappingClassElementImpl

        public MappingClassElementImpl​(String name)
        Creates new MappingClassElementImpl with the corresponding name
        Parameters:
        name - the name of the element
      • MappingClassElementImpl

        public MappingClassElementImpl​(PersistenceClassElement element)
        Creates new MappingClassElementImpl with a corresponding PersistenceClassElement
        Parameters:
        element - the persistence element with which to be associated
    • Method Detail

      • getVersionNumber

        public int getVersionNumber()
        Returns the version number of this MappingClassElement object. Please note, the returned version number reflects the version number at the last save, NOT the version number of the memory representation.
        Specified by:
        getVersionNumber in interface MappingClassElement
        Returns:
        version number
      • hasOldVersionNumber

        public boolean hasOldVersionNumber()
        Returns true if the version number of this MappingClassElement object is older than the current version number of the archiving scheme.
        Specified by:
        hasOldVersionNumber in interface MappingClassElement
        Returns:
        true if it is in need of updating, false otherwise
        See Also:
        getVersionNumber()
      • forName

        public static MappingClassElement forName​(String name,
                                                  Model model)
        Returns the mapping class element associated with the class with the given string name, using the given model object to look it up.
        Parameters:
        name - the fully qualified name of the desired class
        model - the model object to be used to look it up
        Returns:
        mapping class element representing the desired class
      • firePropertyChange

        protected final void firePropertyChange​(String name,
                                                Object o,
                                                Object n)
        Fires property change event. This method overrides that of MappingElementImpl to update the mapping class element's modified status.
        Overrides:
        firePropertyChange in class MappingElementImpl
        Parameters:
        name - property name
        o - old value
        n - new value
      • fireVetoableChange

        protected final void fireVetoableChange​(String name,
                                                Object o,
                                                Object n)
                                         throws PropertyVetoException
        Fires vetoable change event. This method overrides that of MappingElementImpl to give listeners a chance to block changes on the mapping class element modified status.
        Overrides:
        fireVetoableChange in class MappingElementImpl
        Parameters:
        name - property name
        o - old value
        n - new value
        Throws:
        PropertyVetoException - when the change is vetoed by a listener
      • getPersistenceElement

        public final PersistenceClassElement getPersistenceElement()
        Returns:
        persistence class element for this mapping class element
      • setPersistenceElement

        public void setPersistenceElement​(PersistenceClassElement element)
        Set the persistence class element for this mapping class element.
        Parameters:
        element - the persistence class element
      • isModified

        public boolean isModified()
        Gets the modified flag for this mapping class.
        Specified by:
        isModified in interface MappingClassElement
        Returns:
        true if there have been (property) changes to this class, false otherwise.
      • setModified

        public void setModified​(boolean flag)
        Set the modified flag for this mapping class to flag. This is usually set to true by property changes and false after a save.
        Specified by:
        setModified in interface MappingClassElement
        Parameters:
        flag - if true, this class is marked as modified; if false, it is marked as unmodified.
      • getDatabaseRoot

        public String getDatabaseRoot()
        Returns the name of the SchemaElement which represents the database used by the tables mapped to this mapping class.
        Specified by:
        getDatabaseRoot in interface MappingClassElement
        Returns:
        the name of the database root for this mapping class
      • setDatabaseRoot

        public void setDatabaseRoot​(org.netbeans.modules.dbschema.SchemaElement root)
                             throws ModelException
        Set the database root for this MappingClassElement. The root represents the database used by the tables mapped to this mapping class.
        Specified by:
        setDatabaseRoot in interface MappingClassElement
        Parameters:
        root - the new database root
        Throws:
        ModelException - if impossible
      • getTables

        public ArrayList getTables()
        Returns the list of tables (MappingTableElements) used by this mapping class.
        Specified by:
        getTables in interface MappingClassElement
        Returns:
        the meta data tables for this mapping class
      • getTable

        public MappingTableElement getTable​(String name)
        Scans through this mapping class looking for a table whose name matches the name passed in.
        Specified by:
        getTable in interface MappingClassElement
        Parameters:
        name - name of the table to find.
        Returns:
        the meta data table whose name matches the name parameter
      • addTable

        public void addTable​(org.netbeans.modules.dbschema.TableElement table)
                      throws ModelException
        Convenience method which accepts a table element and attempts to add it as either a primary or secondary table depending on the existing list of tables and the foreign keys for the table.
        Specified by:
        addTable in interface MappingClassElement
        Parameters:
        table - table element to be added as either a primary or secondary table.
        Throws:
        ModelException - if impossible
      • setPrimaryTable

        public void setPrimaryTable​(org.netbeans.modules.dbschema.TableElement table)
                             throws ModelException
        Set the primary table for this mapping class to the supplied table.
        Specified by:
        setPrimaryTable in interface MappingClassElement
        Parameters:
        table - table element to be used as the primary table.
        Throws:
        ModelException - if impossible
      • addSecondaryTable

        public MappingReferenceKeyElement addSecondaryTable​(MappingTableElement parentTable,
                                                            org.netbeans.modules.dbschema.TableElement table)
                                                     throws ModelException
        Adds a reference to the supplied table as a secondary table for this mapping class. It creates a MappingReferenceKeyElement for the supplied primary/secondary table pair.
        Specified by:
        addSecondaryTable in interface MappingClassElement
        Parameters:
        parentTable - mapping table element which should also be the primary table.
        table - table element to be used as a secondary table.
        Throws:
        ModelException - if impossible
      • removeTable

        public void removeTable​(MappingTableElement table)
                         throws ModelException
        Removes the reference to the supplied table as a mapped table for this mapping class. This works whether the table is the primary table or a secondary table.
        Specified by:
        removeTable in interface MappingClassElement
        Parameters:
        table - mapping table element to be removed from this mapping class.
        Throws:
        ModelException - if impossible
      • getFields

        public ArrayList getFields()
        Returns the list of fields (MappingFieldElements) in this mapping class. This list includes both local and relationship fields.
        Specified by:
        getFields in interface MappingClassElement
        Returns:
        the mapping fields in this mapping class
      • getField

        public MappingFieldElement getField​(String name)
        Scans through this mapping class looking for a field whose name matches the name passed in.
        Specified by:
        getField in interface MappingClassElement
        Parameters:
        name - name of the field to find.
        Returns:
        the mapping field whose name matches the name parameter
      • isNavigable

        public boolean isNavigable()
        Gets the navigable flag for this mapping class.
        Specified by:
        isNavigable in interface MappingClassElement
        Returns:
        true if lazy initialization will be used, false if access to a non-fetched field will result in an exception. The default is true.
      • setNavigable

        public void setNavigable​(boolean flag)
                          throws ModelException
        Set the navigable flag for this mapping class to flag.
        Specified by:
        setNavigable in interface MappingClassElement
        Parameters:
        flag - if true, lazy initialization will be used; if false, access to a non-fetched field will result in an exception.
        Throws:
        ModelException - if impossible
      • toColumnObjects

        protected static ArrayList toColumnObjects​(String schemaName,
                                                   ArrayList columnNames)
        Accept an arraylist of column names and return an array list containing the corresponding column or column pair objects.
        Parameters:
        schemaName - the database root used to find the column objects
        columnNames - array of column names.
        Returns:
        an array of corresponding column objects
        See Also:
        TableElement.forName(java.lang.String, org.netbeans.modules.dbschema.SchemaElement), TableElement.getMember(org.netbeans.modules.dbschema.DBIdentifier)
      • setFields

        public void setFields​(ArrayList fields)
        Set the list of fields (MappingFieldElements) in this mapping class. This method should only be used internally and for cloning and archiving.
        Parameters:
        fields - the list of mapping fields in this mapping class
      • getProperties

        public int getProperties()
      • postUnarchive

        public void postUnarchive()
                           throws ModelException
        This method is called after a MappingClassElement is unarchived from a .mapping file. This method provides a hook to do any checking (version number checking) and conversion after unarchiving.
        Specified by:
        postUnarchive in interface MappingClassElement
        Throws:
        ModelException - if impossible
      • preArchive

        public void preArchive()
        This method is called prior to storing a MappingClassElement in a .mapping file. This method provides a hook to do any conversion before archiving. Note, the signature of preArchive in the interface MappingClassElement includes a throws clause (ModelException), but the actual implementation does not throw an exception.
        Specified by:
        preArchive in interface MappingClassElement
      • stripSchemaName

        protected void stripSchemaName()
        Boston to Pilsen conversion. This method converts the absolute db element names to relative names and stores the database root (meaning the schema name) in the MappingClassElement. The method is recursively called for all MappingTableElements and MappingFieldElements attached to this MappingClassElement.