Android Open Source - android-core Database Mapping Descriptor






From Project

Back to project page android-core.

License

The source code is released under:

Apache License

If you think the Android project android-core listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/** 
 * [SIMINOV FRAMEWORK]/*from w w w  .jav  a2 s.  co m*/
 * Copyright [2015] [Siminov Software Solution LLP|support@siminov.com]
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 **/

package siminov.core.model;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Map;

import siminov.core.Constants;
import siminov.core.utils.EmptyIterator;


/**
 * Exposes methods to GET and SET Library Descriptor information as per define in DatabaseDescriptor.si.xml or LibraryDescriptor.si.xml  file by application.
  <p>
    <pre>
    
Example:
  {@code
  
  <database-mapping-descriptor>
  
      <!-- General Properties Of Table And Class -->
      
        <!-- TABLE_NAME: Mandatory Field -->
        <!-- CLASS_NAME: Mandatory Field -->
    <entity table_name="name_of_table" class_name="mapped_pojo_class_name">
      
        <!-- Column Properties Required Under This Table -->
        
      <!-- Optional Field -->
      
        <!-- VARIABLE_NAME: Mandatory Field -->
        <!-- COLUMN_NAME: Mandatory Field -->
      <attribute column_name="column_name_of_table" variable_name="class_variable_name">
          
            <!-- Mandatory Field -->
        <property name="type">java_variable_data_type</property>
        
          <!-- Optional Field (Default is false) -->
        <property name="primary_key">true/false</property>
        
          <!-- Optional Field (Default is false) -->
        <property name="not_null">true/false</property>
        
          <!-- Optional Field (Default is false) -->
        <property name="unique">true/false</property>
        
          <!-- Optional Field -->
        <property name="check">condition_to_be_checked (Eg: variable_name 'condition' value; variable_name > 0)</property>
        
          <!-- Optional Field -->
        <property name="default">default_value_of_column (Eg: 0.1)</property>
      
      </attribute>    
  
      
      
      <!-- Index Properties -->
          
      <!-- Optional Field -->
        <!-- NAME: Mandatory Field -->
        <!-- UNIQUE: Optional Field (Default is false) -->
      <index name="name_of_index" unique="true/false">
        <column>column_name_needs_to_add</column>
      </index>
      
      
      
      <!-- Map Relationship Properties -->
          
      <!-- Optional Field's -->  
      <relationships>
          
            <!-- REFER: Mandatory Field -->
            <!-- REFER_TO: Mandatory Field -->
        <one-to-one refer="class_variable_name" refer_to="map_to_pojo_class_name" on_update="cascade/restrict/no_action/set_null/set_default" on_delete="cascade/restrict/no_action/set_null/set_default">
            
            <!-- Optional Field (Default is false) -->
          <property name="load">true/false</property>
        </one-to-one>    
        
          <!-- REFER: Mandatory Field -->
            <!-- REFER_TO: Mandatory Field -->
        <one-to-many refer="class_variable_name" refer_to="map_to_pojo_class_name" on_update="cascade/restrict/no_action/set_null/set_default" on_delete="cascade/restrict/no_action/set_null/set_default">
            
            <!-- Optional Field (Default is false) -->
          <property name="load">true/false</property>
        </one-to-many>    
  
          <!-- REFER: Mandatory Field -->
            <!-- REFER_TO: Mandatory Field -->
        <many-to-one refer="class_variable_name" refer_to="map_to_pojo_class_name" on_update="cascade/restrict/no_action/set_null/set_default" on_delete="cascade/restrict/no_action/set_null/set_default">
            
            <!-- Optional Field (Default is false) -->
          <property name="load">true/false</property>
        </many-to-one>    
  
          <!-- REFER: Mandatory Field -->
            <!-- REFER_TO: Mandatory Field -->
        <many-to-many refer="class_variable_name" refer_to="map_to_pojo_class_name" on_update="cascade/restrict/no_action/set_null/set_default" on_delete="cascade/restrict/no_action/set_null/set_default">
            
            <!-- Optional Field (Default is false) -->
          <property name="load">true/false</property>
        </many-to-many>    
                    
      </relationships>
  
    </entity>
  
  </database-mapping-descriptor>  
    
    }
  
    </pre>
  </p>
 *
 */
public class DatabaseMappingDescriptor implements IDescriptor {

  protected String tableName = null;
  protected String className = null;
  
  protected Map<String, Attribute> attributeBasedOnColumnNames = new LinkedHashMap<String, Attribute>();
  protected Map<String, Attribute> attributeBasedOnVariableNames = new LinkedHashMap<String, Attribute>();
  
  protected Map<String, Index> indexes = new LinkedHashMap<String, Index>();

  protected Map<String, Relationship> relationshipsBasedOnRefer = new LinkedHashMap<String, Relationship>(); 
  protected Map<String, Relationship> relationshipsBasedOnReferTo = new LinkedHashMap<String, Relationship>();
  
  
  /**
   * Get table name.
   * @return Name of table.
   */
  public String getTableName() {
    return this.tableName;
  }
  
  /**
   * Set table name as per defined in DatabaseMappingDescriptor.si.xml file.
   * @param tableName Name of table.
   */
  public void setTableName(final String tableName) {
    this.tableName = tableName;
  }
  
  /**
   * Get POJO class name.
   * @return POJO class name.
   */
  public String getClassName() {
    return this.className;
  }
  
  /**
   * Set POJO class name as per defined in DatabaseMappingDescriptor.si.xml file.
   * @param className POJO class name.
   */
  public void setClassName(final String className) {
    this.className = className;
  }

  /**
   * Check whether column exists based on column name.
   * @param columnName Name of column.
   * @return TRUE: If column exists, FALSE: If column do not exists.
   */
  public boolean containsAttributeBasedOnColumnName(final String columnName) {
    return this.attributeBasedOnColumnNames.containsKey(columnName);
  }
  
  /**
   * Check whether column exists based on variable name.
   * @param variableName Name of variable.
   * @return TRUE: If column exists, FALSE: If column do not exists.
   */
  public boolean containsAttributeBasedOnVariableName(final String variableName) {
    return this.attributeBasedOnVariableNames.containsKey(variableName);
  }
  
  /**
   * Get column based on column name.
   * @param columnName Name of column name.
   * @return Column object.
   */
  public Attribute getAttributeBasedOnColumnName(final String columnName) {
    return this.attributeBasedOnColumnNames.get(columnName);
  }

  /**
   * Get column based on variable name.
   * @param variableName Name of variable.
   * @return Column object.
   */
  public Attribute getAttributeBasedOnVariableName(final String variableName) {
    return this.attributeBasedOnVariableNames.get(variableName);
  }
  
  /**
   * Get all column names.
   * @return Iterator of all column names.
   */
  public Iterator<String> getColumnNames() {
    return this.attributeBasedOnColumnNames.keySet().iterator();
  }
  
  /**
   * Get all columns.
   * @return Iterator of all columns.
   */
  public Iterator<Attribute> getAttributes() {
    return this.attributeBasedOnVariableNames.values().iterator();
  }

  /**
   * Add column to DatabaseMapping object.
   * @param attribute Column object.
   */
  public void addAttribute(final Attribute attribute) {
    this.attributeBasedOnVariableNames.put(attribute.getVariableName(), attribute);
    this.attributeBasedOnColumnNames.put(attribute.getColumnName(), attribute);
  }
  
  /**
   * Remove column based on variable name.
   * @param variableName Name of variable.
   */
  public void removeAttributeBasedOnVariableName(final String variableName) {
    removeAttribute(getAttributeBasedOnVariableName(variableName));
  }
  
  /**
   * Remove column based on column name.
   * @param columnName Name of column.
   */
  public void removeAttributeBasedOnColumnName(final String columnName) {
    removeAttribute(getAttributeBasedOnColumnName(columnName));
  }
  
  /**
   * Remove column based on column object.
   * @param attribute Column object which need to be removed.
   */
  public void removeAttribute(final Attribute attribute) {
    this.attributeBasedOnColumnNames.values().remove(attribute);
  }
  
  /**
   * Check whether index exists based in index name.
   * @param indexName Name of index.
   * @return TRUE: If index exists, FALSE: If index do not exists.
   */
  public boolean containsIndex(final String indexName) {
    return this.indexes.containsKey(indexName);
  }
  
  /**
   * Get index object based on index name.
   * @param indexName Name of index.
   * @return Index object.
   */
  public Index getIndex(final String indexName) {
    return this.indexes.get(indexName);
  }
  
  /**
   * Get all index names.
   * @return Iterator which contains all index names.
   */
  public Iterator<String> getIndexNames() {
    return this.indexes.keySet().iterator();
  }
  
  /**
   * Get all indexes.
   * @return Iterator which contain all indexes.
   */
  public Iterator<Index> getIndexes() {
    return this.indexes.values().iterator();
  }
  
  /**
   * Add index to DatabaseMapping object.
   * @param index Index object.
   */
  public void addIndex(final Index index) {
    this.indexes.put(index.getName(), index);
  }
  
  /**
   * Remove index object.
   * @param indexName Name of index.
   */
  public void removeIndexBasedOnName(final String indexName) {
    removeIndex(getIndex(indexName));
  }
  
  /**
   * Remove index object.
   * @param index Index object.
   */
  public void removeIndex(final Index index) {
    this.indexes.remove(index.getName());
  }


  /**
   * Get iterator of relationship objects. 
   * @return Relationship objects.
   */
  public Iterator<Relationship> getRelationships() {
    return this.relationshipsBasedOnRefer.values().iterator();
  }
  
  /**
   * Get iterator of relationship objects based on refer.
   * @param refer Name of refer.
   * @return Relationship object based on refer.
   */
  public Relationship getRelationshipBasedOnRefer(String refer) {
    return this.relationshipsBasedOnRefer.get(refer);
  }
  
  /**
   * Get relationship object based on refer to.
   * @param referTo Name of refer to.
   * @return Relationship object based on refer to.
   */
  public Relationship getRelationshipBasedOnReferTo(String referTo) {
    return this.relationshipsBasedOnReferTo.get(referTo);
  }
  
  /**
   * Get one to one relationship object.
   * @return Iterator of relationship objects.
   */
  public Iterator<Relationship> getOneToOneRelationships() {
    
    Collection<Relationship> oneToOneRelationships = new ArrayList<Relationship>();
    Collection<Relationship> relationships = relationshipsBasedOnRefer.values();

    Iterator<Relationship> relationshipsIterator = relationships.iterator();
    while(relationshipsIterator.hasNext()) {
      Relationship relationship = relationshipsIterator.next();
      
      if(relationship.getRelationshipType().equalsIgnoreCase(Constants.DATABASE_MAPPING_DESCRIPTOR_RELATIONSHIPS_ONE_TO_ONE)) {
        oneToOneRelationships.add(relationship);
      }
    }
  
    return oneToOneRelationships.iterator();
  }
  
  /**
   * Get one to many relationship object.
   * @return Iterator of relationship objects.
   */
  public Iterator<Relationship> getOneToManyRelationships() {

    Collection<Relationship> oneToManyRelationships = new ArrayList<Relationship>();
    Collection<Relationship> relationships = relationshipsBasedOnRefer.values();

    Iterator<Relationship> relationshipsIterator = relationships.iterator();
    while(relationshipsIterator.hasNext()) {
      Relationship relationship = relationshipsIterator.next();
      
      if(relationship.getRelationshipType().equalsIgnoreCase(Constants.DATABASE_MAPPING_DESCRIPTOR_RELATIONSHIPS_ONE_TO_MANY)) {
        oneToManyRelationships.add(relationship);
      }
    }
  
    return oneToManyRelationships.iterator();
  }
  
  /**
   * Get many to one relationship object.
   * @return Iterator of relationship objects.
   */
  public Iterator<Relationship> getManyToOneRelationships() {
    
    Collection<Relationship> manyToOneRelationships = new ArrayList<Relationship>();
    Collection<Relationship> relationships = relationshipsBasedOnRefer.values();

    Iterator<Relationship> relationshipsIterator = relationships.iterator();
    while(relationshipsIterator.hasNext()) {
      Relationship relationship = relationshipsIterator.next();
      
      if(relationship.getRelationshipType().equalsIgnoreCase(Constants.DATABASE_MAPPING_DESCRIPTOR_RELATIONSHIPS_MANY_TO_ONE)) {
        manyToOneRelationships.add(relationship);
      }
    }
  
    return manyToOneRelationships.iterator();
  }
  
  /**
   * Get many to many relationship object.
   * @return Iterator of relationship objects.
   */
  public Iterator<Relationship> getManyToManyRelationships() {
    
    Collection<Relationship> manyToManyRelationships = new ArrayList<Relationship>();
    Collection<Relationship> relationships = relationshipsBasedOnRefer.values();

    Iterator<Relationship> relationshipsIterator = relationships.iterator();
    while(relationshipsIterator.hasNext()) {
      Relationship relationship = relationshipsIterator.next();
      
      if(relationship.getRelationshipType().equalsIgnoreCase(Constants.DATABASE_MAPPING_DESCRIPTOR_RELATIONSHIPS_MANY_TO_MANY)) {
        manyToManyRelationships.add(relationship);
      }
    }
  
    return manyToManyRelationships.iterator();
  }
  
  /**
   * Add relationship object.
   * @param relationship Relationship object.
   */
  public void addRelationship(Relationship relationship) {
    this.relationshipsBasedOnRefer.put(relationship.getRefer(), relationship);
    this.relationshipsBasedOnReferTo.put(relationship.getRefer(), relationship);
  }

  
  /**
   * Get all Properties defined in descriptor.
   * @return All Property Values.
   */
  public Iterator<String> getProperties() {
    return new EmptyIterator<String>();
  }
  
  /**
   * Get Property based on name provided.
   * @param name Name of Property.
   * @return Property value.
   */
  public String getProperty(String name) {
    return null;
  }

  /**
   * Check whether Property exist or not.
   * @param name Name of Property.
   * @return true/false, TRUE if property exist, FALSE if property does not exist.
   */
  public boolean containProperty(String name) {
    return false;
  }
  
  /**
   * Add Property in property pool.
   * @param name Name of Property.
   * @param value value of Property.
   */
  public void addProperty(String name, String value) {
    
  }
  
  /**
   * Remove Property from property pool.
   * @param name Name of Property.
   */
  public void removeProperty(String name) {
    
  }
  
  /**
   * Exposes methods to GET and SET Column information as per define in DatabaseMappingDescriptor.si.xml file by application.
  <p>
    <pre>
    
Example:
  {@code

  <database-mapping>
  
    <table table_name="LIQUOR" class_name="siminov.core.sample.model.Liquor">
      
      <column variable_name="liquorType" column_name="LIQUOR_TYPE">
        <property name="type">TEXT</property>
        <property name="primary_key">true</property>
        <property name="not_null">true</property>
        <property name="unique">true</property>
      </column>    
      
  </database-mapping>
  }
  
    </pre>
  </p>
   *
   */
  public static class Attribute implements IDescriptor {
    private String variableName = null;
    private String columnName = null;

    private String getterMethodName = null;
    private String setterMethodName = null;

    private Map<String, String> properties = new HashMap<String, String> ();
    
    
    /**
     * Get variable name.
     */
    public String getVariableName() {
      return this.variableName;
    }
    
    /**
     * Set variable name as per defined in DatabaseMapping.core.xml file.
     * @param variableName Name of variable.
     */
    public void setVariableName(final String variableName) {
      this.variableName = variableName;
    }
    
    /**
     * Get column name.
     * @return Name Of Column. 
     */
    public String getColumnName() {
      return this.columnName;
    }
    
    /**
     * Set column name as per defined in DatabaseMapping.core.xml file.
     * @param columnName Name of column name.
     */
    public void setColumnName(final String columnName) {
      this.columnName = columnName;
    }
    
    /**
     * Get type of column.
     * @return Type of column.
     */
    public String getType() {
      return this.properties.get(Constants.DATABASE_MAPPING_DESCRIPTOR_TYPE);
    }
    
    /**
     * Set type of column as per defined in DatabaseMapping.core.xml file.
     * @param type Type of column.
     */
    public void setType(final String type) {
      this.properties.put(Constants.DATABASE_MAPPING_DESCRIPTOR_TYPE, type);
    }
    
    /**
     * Get POJO class column getter method name.
     * @return POJO class column getter method name.
     */
    public String getGetterMethodName() {
      return this.getterMethodName;
    }
    
    /**
     * Set POJO class column getter method name.
     * @param getMethodName POJO class coumn getter method name. 
     */
    public void setGetterMethodName(final String getMethodName) {
      this.getterMethodName = getMethodName;
    }
    
    /**
     * Get POJO class column setter method name.
     * @return POJO class column setter method name.
     */
    public String getSetterMethodName() {
      return this.setterMethodName;
    }
    
    /**
     * Set POJO class column setter method name.
     * @param setMethodName POJO class column setter method name.
     */
    public void setSetterMethodName(final String setMethodName) {
      this.setterMethodName = setMethodName;
    }
    
    /**
     * Get default value of column.
     * @return Default value of column.
     */
    public String getDefaultValue() {
      return this.properties.get(Constants.DATABASE_MAPPING_DESCRIPTOR_DEFAULT_VALUE);
    }
    
    /**
     * Set default value of column as per defined in DatabaseMapping.core.xml file.
     * @param defaultValue Default value of column.
     */
    public void setDefaultValue(final String defaultValue) {
      this.properties.put(Constants.DATABASE_MAPPING_DESCRIPTOR_DEFAULT_VALUE, defaultValue);
    }
    
    /**
     * Get check constraint of column.
     * @return Check constraint of column.
     */
    public String getCheck() {
      return this.properties.get(Constants.DATABASE_MAPPING_DESCRIPTOR_CHECK);
    }
    
    /**
     * Set check constraint of column as per defined in DatabaseMapping.core.xml file.
     * @param check Check constraint.
     */
    public void setCheck(final String check) {
      this.properties.put(Constants.DATABASE_MAPPING_DESCRIPTOR_CHECK, check);
    }
    
    /**
     * Check whether column is primary key.
     * @return TRUE: If column is primary key, FALSE: If column is not primary key.
     */
    public boolean isPrimaryKey() {
      String primaryKey = this.properties.get(Constants.DATABASE_MAPPING_DESCRIPTOR_PRIMARY_KEY);
      if(primaryKey == null || primaryKey.length() <= 0) {
        return false;
      } else if(primaryKey != null && primaryKey.length() > 0 && primaryKey.equalsIgnoreCase("true")) {
        return true;
      }
      
      return false;
    }
    
    /**
     * Set column as primary key or not.
     * @param primaryKey TRUE: If column is primary key, FALSE: If column is not primary key.
     */
    public void setPrimaryKey(final boolean primaryKey) {
      this.properties.put(Constants.DATABASE_MAPPING_DESCRIPTOR_PRIMARY_KEY, Boolean.toString(primaryKey));
    }
    
    /**
     * Check whether column is unique or not.
     * @return TRUE: If column is unique, FALSE: If column is not unique.
     */
    public boolean isUnique() {
      String unique = this.properties.get(Constants.DATABASE_MAPPING_DESCRIPTOR_UNIQUE);
      if(unique == null || unique.length() <= 0) {
        return false;
      } else if(unique != null && unique.length() > 0 && unique.equalsIgnoreCase("true")) {
        return true;
      }
      
      return false;
    }
    
    /**
     * Set whether column is unique or not.
     * @param isUnique TRUE: If column is unique, FALSE: If column is not unique
     */
    public void setUnique(final boolean isUnique) {
      this.properties.put(Constants.DATABASE_MAPPING_DESCRIPTOR_UNIQUE, Boolean.toString(isUnique));
    }
    
    /**
     * Check whether column value can be not or not.
     * @return TRUE: If column value can be null, FALSE: If column value can not be null.
     */
    public boolean isNotNull() {
      String notNull = this.properties.get(Constants.DATABASE_MAPPING_DESCRIPTOR_NOT_NULL);
      if(notNull == null || notNull.length() <= 0) {
        return false;
      } else if(notNull != null && notNull.length() > 0 && notNull.equalsIgnoreCase("true")) {
        return true;
      }
      
      return false;
    }
    
    /**
     * Set whether column can be null or not.
     * @param isNotNull TRUE: If column value can be null, FALSE: If column value can not be null.
     */
    public void setNotNull(final boolean isNotNull) {
      this.properties.put(Constants.DATABASE_MAPPING_DESCRIPTOR_NOT_NULL, Boolean.toString(isNotNull));
    }
    
    /**
     * Get all Properties defined in descriptor.
     * @return All Property Values.
     */
    public Iterator<String> getProperties() {
      return this.properties.keySet().iterator();
    }
    
    /**
     * Get Property based on name provided.
     * @param name Name of Property.
     * @return Property value.
     */
    public String getProperty(String name) {
      return this.properties.get(name);
    }

    /**
     * Check whether Property exist or not.
     * @param name Name of Property.
     * @return true/false, TRUE if property exist, FALSE if property does not exist.
     */
    public boolean containProperty(String name) {
      return this.properties.containsKey(name);
    }
    
    /**
     * Add Property in property pool.
     * @param name Name of Property.
     * @param value value of Property.
     */
    public void addProperty(String name, String value) {
      this.properties.put(name, value);
    }
    
    /**
     * Remove Property from property pool.
     * @param name Name of Property.
     */
    public void removeProperty(String name) {
      this.properties.remove(name);
    }
  }

  
  /**
   * Exposes methods to GET and SET Reference Map information as per define in DatabaseMappingDescriptor.si.xml file by application.
  <p>
    <pre>
  
Example:
  {@code
  <index name="LIQUOR_INDEX_BASED_ON_LINK" unique="true">
    <column>HISTORY</column>
  </index>
  }
  
    </pre>
  </p>
   *
   */
  public static class Index implements IDescriptor {
    private String name = null;
    private Collection<String> columns = new LinkedList<String> ();

    private boolean unique;
  
    /**
     * Get index name.
     * @return Index Name.
     */
    public String getName() {
      return this.name;
    }
    
    /**
     * Set index name as per defined in DatabaseMapping.core.xml file.
     * @param name Index Name.
     */
    public void setName(final String name) {
      this.name = name;
    }
    
    /**
     * Check whether index should be unique or not.
     * @return TRUE: If index is unique, FALSE: If index is not unqiue.
     */
    public boolean isUnique() {
      return this.unique;
    }
    
    /**
     * Set whether unqiue is unique or not.
     * @param unique TRUE: If index is unique, FALSE: If index is not unique.
     */
    public void setUnique(final boolean unique) {
      this.unique = unique;
    }  
    
    /**
     * Check whether index contain column or not.
     * @param column Name of column.
     * @return TRUE: If index contains column, FALSE: If index does not contain column.
     */
    public boolean containsColumn(final String column) {
      return this.columns.contains(column);
    }
    
    /**
     * Get all columns.
     * @return Iterator which contain all columns.
     */
    public Iterator<String> getColumns() {
      return this.columns.iterator();
    }
    
    /**
     * Add column to index.
     * @param column Name of column.
     */
    public void addColumn(final String column) {
      this.columns.add(column);
    }

    /**
     * Remove column from index.
     * @param column Name of column.
     */
    public void removeColumn(final String column) {
      this.columns.remove(column);
    }
    
    public Iterator<String> getProperties() {
      return new EmptyIterator<String>();
    }

    /**
     * Get Property based on name provided.
     * @param name Name of Property.
     * @return Property value.
     */
    public String getProperty(String name) {
      return null;
    }

    /**
     * Check whether Property exist or not.
     * @param name Name of Property.
     * @return true/false, TRUE if property exist, FALSE if property does not exist.
     */
    public boolean containProperty(String name) {
      return false;
    }
    
    /**
     * Add Property in property pool.
     * @param name Name of Property.
     * @param value value of Property.
     */
    public void addProperty(String name, String value) {
      
    }
    
    /**
     * Remove Property from property pool.
     * @param name Name of Property.
     */
    public void removeProperty(String name) {
      
    }
  }

  /**
   * Contains relationship details.
   */
  public static class Relationship implements IDescriptor {
    
    private String relationshipType = null;
    
    private String refer = null;
    private String referTo = null;
    
    private String onUpdate = null;
    private String onDelete = null;

    private String getterReferMethodName = null;
    private String setterReferMethodName = null;
    
    private Map<String, String> properties = new HashMap<String, String> ();
    
    private DatabaseMappingDescriptor referedDatabaseMappingDescriptor = null;
    
    /**
     * Get relationship type.
     * @return Type of relationship.
     */
    public String getRelationshipType() {
      return this.relationshipType;
    }
    
    /**
     * Set relationship type.
     * @param relationshipType Type of relationship.
     */
    public void setRelationshipType(String relationshipType) {
      this.relationshipType = relationshipType;
    }
    
    /**
     * Get refer.
     * @return Name of refer.
     */
    public String getRefer() {
      return this.refer;
    }
    
    /**
     * Set refer.
     * @param refer Name of refer.
     */
    public void setRefer(String refer) {
      this.refer = refer;
    }
    
    /**
     * Get refer to.
     * @return Name of refer to.
     */
    public String getReferTo() {
      return this.referTo;
    }

    /**
     * Set refer to.
     * @param referTo Name of refer to.
     */
    public void setReferTo(String referTo) {
      this.referTo = referTo;
    }
    
    /**
     * Get on update.
     * @return Action on update.
     */
    public String getOnUpdate() {
      return this.onUpdate;
    }
    
    /**
     * Set on update.
     * @param onUpdate Action on update.
     */
    public void setOnUpdate(String onUpdate) {
      this.onUpdate = onUpdate;
    }
    
    /**
     * Get on delete.
     * @return Action on delete.
     */
    public String getOnDelete() {
      return this.onDelete;
    }
    
    /**
     * Set on delete.
     * @param onDelete Action on delete.
     */
    public void setOnDelete(String onDelete) {
      this.onDelete = onDelete;
    }
    
    /**
     * Get getter refer method name.
     * @return Getter refer method name.
     */
    public String getGetterReferMethodName() {
      return this.getterReferMethodName;
    }
    
    /**
     * Set getter refer method name.
     * @param getterReferMethodName Name of getter refer method name.
     */
    public void setGetterReferMethodName(String getterReferMethodName) {
      this.getterReferMethodName = getterReferMethodName;
    }
    
    /**
     * Get setter refer method name.
     * @return Name of setter refer method name.
     */
    public String getSetterReferMethodName() {
      return this.setterReferMethodName;
    }
    
    /**
     * Set setter refer method name.
     * @param setterReferMethodName Name of setter refer name.
     */
    public void setSetterReferMethodName(String setterReferMethodName) {
      this.setterReferMethodName = setterReferMethodName;
    }
    
    /**
     * Check whether load property value is set to TRUE/FASLE.
     * @return TRUE: If load property value is set to true; FALSE: If load property value is set to false.
     */
    public boolean isLoad() {
      String load = this.properties.get(Constants.DATABASE_MAPPING_DESCRIPTOR_RELATIONSHIPS_LOAD);
      if(load == null || load.length() <= 0) {
        return false;
      } else if(load != null && load.length() > 0 && load.equalsIgnoreCase("true")) {
        return true;
      }
      
      return false;
    }
    
    /**
     * Set load property value.
     * @param load TRUE: If load property value is true; FALSE: If load property value is false.
     */
    public void setLoad(boolean load) {
      this.properties.put(Constants.DATABASE_MAPPING_DESCRIPTOR_RELATIONSHIPS_LOAD, Boolean.toString(load));
    }
    
    /**
     * Get all Properties defined in descriptor.
     * @return All Property Values.
     */
    public Iterator<String> getProperties() {
      return this.properties.keySet().iterator();
    }
    
    /**
     * Get Property based on name provided.
     * @param name Name of Property.
     * @return Property value.
     */
    public String getProperty(String name) {
      return this.properties.get(name);
    }

    /**
     * Check whether Property exist or not.
     * @param name Name of Property.
     * @return true/false, TRUE if property exist, FALSE if property does not exist.
     */
    public boolean containProperty(String name) {
      return this.properties.containsKey(name);
    }
    
    /**
     * Add Property in property pool.
     * @param name Name of Property.
     * @param value value of Property.
     */
    public void addProperty(String name, String value) {
      this.properties.put(name, value);
    }
    
    /**
     * Remove Property from property pool.
     * @param name Name of Property.
     */
    public void removeProperty(String name) {
      this.properties.remove(name);
    }
    
    
    /**
     * Get database mapping descriptor object.
     * @return DatabaseMappingDescriptor object.
     */
    public DatabaseMappingDescriptor getReferedDatabaseMappingDescriptor() {
      return this.referedDatabaseMappingDescriptor;
    }
    
    /**
     * Set refered database mapping descriptor object.
     * @param referedDatabaseMappingDescriptor DatabaseMappingDescriptor object.
     */
    public void setReferedDatabaseMappingDescriptor(DatabaseMappingDescriptor referedDatabaseMappingDescriptor) {
      this.referedDatabaseMappingDescriptor = referedDatabaseMappingDescriptor;
    }
  }
}




Java Source Code List

siminov.core.Constants.java
siminov.core.IInitializer.java
siminov.core.Initializer.java
siminov.core.Siminov.java
siminov.core.database.Clause.java
siminov.core.database.DatabaseBundle.java
siminov.core.database.DatabaseFactory.java
siminov.core.database.DatabaseHelper.java
siminov.core.database.DatabaseUtils.java
siminov.core.database.Database.java
siminov.core.database.Where.java
siminov.core.database.design.IAverageClause.java
siminov.core.database.design.IAverage.java
siminov.core.database.design.ICountClause.java
siminov.core.database.design.ICount.java
siminov.core.database.design.IDataTypeHandler.java
siminov.core.database.design.IDatabaseImpl.java
siminov.core.database.design.IDatabase.java
siminov.core.database.design.IDeleteClause.java
siminov.core.database.design.IDelete.java
siminov.core.database.design.IGroupConcatClause.java
siminov.core.database.design.IGroupConcat.java
siminov.core.database.design.IMaxClause.java
siminov.core.database.design.IMax.java
siminov.core.database.design.IMinClause.java
siminov.core.database.design.IMin.java
siminov.core.database.design.IQueryBuilder.java
siminov.core.database.design.ISelectClause.java
siminov.core.database.design.ISelect.java
siminov.core.database.design.ISumClause.java
siminov.core.database.design.ISum.java
siminov.core.database.design.ITotalClause.java
siminov.core.database.design.ITotal.java
siminov.core.database.sqlite.DataTypeHandler.java
siminov.core.database.sqlite.DatabaseImpl.java
siminov.core.database.sqlite.QueryBuilder.java
siminov.core.events.EventHandler.java
siminov.core.events.IDatabaseEvents.java
siminov.core.events.ISiminovEvents.java
siminov.core.exception.DatabaseException.java
siminov.core.exception.DeploymentException.java
siminov.core.exception.IException.java
siminov.core.exception.PrematureEndOfParseException.java
siminov.core.exception.SiminovCriticalException.java
siminov.core.exception.SiminovException.java
siminov.core.log.Log.java
siminov.core.model.ApplicationDescriptor.java
siminov.core.model.DatabaseDescriptor.java
siminov.core.model.DatabaseMappingDescriptor.java
siminov.core.model.IDescriptor.java
siminov.core.model.LibraryDescriptor.java
siminov.core.reader.ApplicationDescriptorReader.java
siminov.core.reader.DatabaseDescriptorReader.java
siminov.core.reader.DatabaseMappingDescriptorReader.java
siminov.core.reader.LibraryDescriptorReader.java
siminov.core.reader.QuickDatabaseMappingDescriptorReader.java
siminov.core.reader.SiminovSAXDefaultHandler.java
siminov.core.resource.ResourceManager.java
siminov.core.utils.ClassUtils.java
siminov.core.utils.EmptyIterator.java
siminov.core.utils.Utils.java