public void TableInfoFind(TableName _TableName)
{
PBU_TableInfo _TableInfo;
DictTable dTable;
SysDictTable sDictTable;
DictField df;
DictType dt;
DictIndex di;
IndexId indexId;
int i,ii, fId, tId;
str strFieldName;
str strFieldLable;
str strMandatory;
str strSystem;
str strType;
str strEDTorEnumType;
str strEDTofEnumName;
str strPrimaryKey;
str strVisible;
str strAllowEdit;
str strAllowEditOnCreate;
List methodList = new List(Types::String);
ListEnumerator enumerator;
//tId = tablenum(_TableName);
tId = tableName2id(_TableName);
dTable = new DictTable(tId);
if (dTable)
{
for (i=1; i <= dTable.fieldCnt(); i++)
{
fId = dTable.fieldCnt2Id(i);
df = new DictField(tId, fId);
//System
if(df.isSystem())
{
strSystem = "System";
}
else
{
strSystem = "General";
}
//Field Name
strFieldName = (df ? df.name() : "");
//Field Lable
strFieldLable = (df ? df.label() : "");
//Field Mandatory
if (df.mandatory())
{
strMandatory = "Yes";
}
//Type
if (df.baseType() == Types::String)
{
strType = strFmt("%1 %2",df.baseType(),df.stringLen());
}
else
{
strType = strFmt("%1",df.baseType());
}
//EDT or Enum
dt = new DictType(df.typeId());
if (strType == "Enum")
{
if(df.enumId())
{
strEDTorEnumType = "Enum";
strEDTofEnumName = enumId2Name(df.enumId());
}
}
else if (strType != "Enum")
{
if (dt)
{
strEDTorEnumType = "EDT";
strEDTofEnumName = dt.name();
}
}
else
{
strEDTorEnumType = "";
}
//Primary Key
for (indexId = dTable.indexNext(0); indexId; indexId = dTable.indexNext(indexId))// loop index of table
{
di = dTable.indexObject(indexId); // get dictIndex from dictTable
if (!di.allowDuplicates()) // check if index property allowDuplicates is true or false
{
for (ii=1; ii<=di.numberOfFields(); ii++) // loop thru fields of index
{
if (di.field(ii) == fId) // get fieldId of the current field
{
strPrimaryKey = "Yes";
}
}
}
}
//Visible
if (df.visible())
{
strVisible = "Yes";
}
else
{
strVisible = "No";
}
//AllowEdit
if (df.allowEdit())
{
strAllowEdit = "Yes";
}
else
{
strAllowEdit = "No";
}
//AllowEditOnCreate
if (df.allowEditOnCreate())
{
strAllowEditOnCreate = "Yes";
}
else
{
strAllowEditOnCreate = "No";
}
_TableInfo.clear();
_TableInfo.FieldSystemOrGeneral = strSystem;
_TableInfo.FieldName = strFieldName;
_TableInfo.FieldLable = strFieldLable;
_TableInfo.FieldMandatory = strMandatory;
_TableInfo.FieldType = strType;
_TableInfo.FieldEDTorEnum = strEDTorEnumType;
_TableInfo.FieldEDTorEnumName = strEDTofEnumName;
_TableInfo.FieldPrimaryKey = strPrimaryKey;
_TableInfo.FieldVisible = strVisible;
_TableInfo.FieldAllowEdit = strAllowEdit;
_TableInfo.FieldAllowEditOnCreate = strAllowEditOnCreate;
_TableInfo.insert();
//변수 초기화
strSystem = "";
strFieldName = "";
strFieldLable = "";
strMandatory = "";
strType = "";
strEDTorEnumType = "";
strEDTofEnumName = "";
strPrimaryKey = "";
strVisible = "";
strAllowEdit = "";
strAllowEditOnCreate = "";
}
//임시소스입니다.
sDictTable = new SysDictTable(tableName2id(_TableName));
methodList =sDictTable.getListOfDisplayMethods();
enumerator = methodList.getEnumerator();
while(enumerator.moveNext())
{
_TableInfo.clear();
_TableInfo.FieldName = strReplace(strReplace(strReplace(enumerator.toString(),"[",""),"]",""),'"',"")+"()";
_TableInfo.FieldType = "Display";
if (_TableInfo.FieldName)
{
_TableInfo.insert();
}
}
}
PBU_TableInfo.setTmpData(_TableInfo);
PBU_TableInfo_DS.executeQuery();
}
No comments:
Post a Comment