Android Open Source - Glowplug Glowplug Relationship






From Project

Back to project page Glowplug.

License

The source code is released under:

MIT License

If you think the Android project Glowplug 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

package com.adecker.glowplug;
//w ww.  ja  v a 2s.  c  om
import com.adecker.glowplugannotations.GlowplugType;

import java.util.ArrayList;

/**
 * Created by alex on 12/12/13.
 */
public class GlowplugRelationship extends GlowplugProperty {

  private final String tableName;
  private final String name;
  private String sqliteName;
  private String remoteName;
  private final String foreignTable;
  private final String foreignKey;
    private final int index;

  private boolean manyToMany;

  private ArrayList<String> constraints = new ArrayList<String>();

  public GlowplugRelationship(String tableName, String name, String foreignTable, String foreignKey, int index) {
    this.tableName = tableName;
    this.name = name;
    this.foreignTable = foreignTable;
    this.foreignKey = foreignKey;

        this.index = index;

    this.sqliteName = this.name;
    this.remoteName = this.name;
  }

    @Override
  public String getName() {
    return name;
  }

    @Override
    public String getSqliteName() {
        return sqliteName;
    }

    @Override
    public String getRemoteName() {
        return remoteName;
    }

    @Override
  public String getFQName() {
    return tableName + "." + getSqliteName();
  }

    public String getNaturalJoin() {
        return getFQName() + "=" + getForeignTable()+"."+getForeignKey();
    }

    @Override
    public GlowplugType getType() {
        return GlowplugType.LONG;
    }

    @Override
    public int getIndex() {
        return index;
    }

    public String getForeignTable() {
    return foreignTable;
  }

  public String getForeignKey() {
    return foreignKey;
  }

  public boolean isManyToMany() {
    return manyToMany;
  }

  public ArrayList<String> getConstraints() {
    return constraints;
  }

  /**
   * @return The name of the relationship tablename if this relationship is many-to-many or null
   */
  public String getManyToManyTableName() {
    if (!manyToMany) {
      return null;
    } else {
      return tableName + "_" + foreignTable;
    }
  }

  public GlowplugRelationship setSqliteName(String sqliteName) {
    if (!sqliteName.isEmpty()) {
      this.sqliteName = sqliteName;
    }
    return this;
  }

  public GlowplugRelationship setRemoteName(String remoteName) {
    if (!remoteName.isEmpty()) {
      this.remoteName = remoteName;
    }
    return this;
  }

  public GlowplugRelationship addConstraint(String constraint) {
    constraints.add(constraint);
    return this;
  }

}




Java Source Code List

com.adecker.glowplug.GlowplugAttribute.java
com.adecker.glowplug.GlowplugContentProvider.java
com.adecker.glowplug.GlowplugEntity.java
com.adecker.glowplug.GlowplugOpenHelper.java
com.adecker.glowplug.GlowplugProperty.java
com.adecker.glowplug.GlowplugRelationship.java
com.adecker.glowplugannotations.Attribute.java
com.adecker.glowplugannotations.Entity.java
com.adecker.glowplugannotations.GlowplugType.java
com.adecker.glowplugannotations.Model.java
com.adecker.glowplugannotations.Relationship.java
com.adecker.glowplugcompiler.EntityProcessor.java
com.adecker.glowplugcompiler.Util.java
com.adecker.glowplugcompiler.VariableParser.java
com.adecker.glowplugcompiler.example.ActorListFragment.java
com.adecker.glowplugcompiler.example.FilmListFragment.java
com.adecker.glowplugcompiler.example.MainActivity.java
com.adecker.glowplugcompiler.example.model.DataModel.java
com.adecker.glowplugcompiler.example.model.MyActor.java
com.adecker.glowplugcompiler.example.model.MyFilm.java
com.adecker.glowplugcompiler.example.model.SakilaHelper.java
.file.java