Skip to content

Commit

Permalink
change table alias from v... to V...
Browse files Browse the repository at this point in the history
  • Loading branch information
fpriyatna committed Sep 20, 2019
1 parent 9657a60 commit e0d598e
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ object Constants {
//aliases
val URI_AS_ALIAS="uri_";
val RANGE_TABLE_ALIAS="rt_";
val VIEW_ALIAS="v_";
val VIEW_ALIAS="V_";
val TABLE_ALIAS_PREFIX="t_";
val VIEW_ALIAS_RANDOM_LIMIT=100000;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,74 +5,75 @@ import es.upm.fi.dia.oeg.morph.base.Constants
import Zql.ZExp
import java.util.Random

class SQLFromItem(fullName:String , val form:Constants.LogicalTableType.Value)
extends ZFromItem(fullName) with SQLLogicalTable {
var joinType:String=null;
var onExp:ZExp =null;

override def generateAlias() :String ={
//return R2OConstants.VIEW_ALIAS + this.hashCode();
val alias = super.getAlias();
if(alias == null || alias.equals("")) {
class SQLFromItem(fullName:String , val form:Constants.LogicalTableType.Value)
extends ZFromItem(fullName) with SQLLogicalTable {
var joinType:String=null;
var onExp:ZExp =null;



override def generateAlias() :String ={
//return R2OConstants.VIEW_ALIAS + this.hashCode();
val alias = super.getAlias();
if(alias == null || alias.equals("")) {
val generatedAlias = Constants.VIEW_ALIAS + new Random().nextInt(Constants.VIEW_ALIAS_RANDOM_LIMIT);
//val generatedAlias = "T" + SQLFromItem.inc;

super.setAlias(generatedAlias);
}
super.getAlias();
}

override def toString() : String = {
this.print(true)
}



def setJoinType(joinType:String ) = { this.joinType = joinType; }

def setOnExp(onExp:ZExp ) = { this.onExp = onExp; }

def getOnExp() : ZExp = { this.onExp; }

def getJoinType() : String = { joinType; }

override def print(withAlias:Boolean ) : String = {
val alias = this.getAlias();
this.setAlias("");

val result = if(alias != null && withAlias) {
val resultAux = if(this.form == Constants.LogicalTableType.TABLE_NAME) {
val tableName = super.toString().trim();
tableName + " " + alias;
} else {
"(" + super.toString() + ") " + alias;
}
resultAux
} else {
val tableName = super.toString();
tableName;
}


if(alias != null) { this.setAlias(alias); }

return result;
}

// def setDatabaseType(dbType:String ) = { this.dbType = dbType; }

// def getDbType() : String = { dbType; }

super.setAlias(generatedAlias);
}
super.getAlias();
}

override def toString() : String = {
this.print(true)
}



def setJoinType(joinType:String ) = { this.joinType = joinType; }

def setOnExp(onExp:ZExp ) = { this.onExp = onExp; }

def getOnExp() : ZExp = { this.onExp; }

def getJoinType() : String = { joinType; }

override def print(withAlias:Boolean ) : String = {
val alias = this.getAlias();
this.setAlias("");

val result = if(alias != null && withAlias) {
val resultAux = if(this.form == Constants.LogicalTableType.TABLE_NAME) {
val tableName = super.toString().trim();
tableName + " " + alias;
//tableName + " \"" + alias + "\"";
} else {
"(" + super.toString() + ") " + alias;
}
resultAux
} else {
val tableName = super.toString();
tableName;
}


if(alias != null) { this.setAlias(alias); }

return result;
}

// def setDatabaseType(dbType:String ) = { this.dbType = dbType; }

// def getDbType() : String = { dbType; }
}

object SQLFromItem {
private var current = 0
private def inc = {current += 1; current}
def apply(fullName:String, form:Constants.LogicalTableType.Value, dbType:String) = {
val sqlFromItem = new SQLFromItem(fullName, form);
sqlFromItem.databaseType = dbType;
sqlFromItem;
}

def apply(fullName:String, form:Constants.LogicalTableType.Value, dbType:String) = {
val sqlFromItem = new SQLFromItem(fullName, form);
sqlFromItem.databaseType = dbType;
sqlFromItem;
}
}

0 comments on commit e0d598e

Please sign in to comment.