-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDataEntitiesMetadataExport.xpp
More file actions
116 lines (102 loc) · 4.63 KB
/
DataEntitiesMetadataExport.xpp
File metadata and controls
116 lines (102 loc) · 4.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
class DataEntitiesMetadataExport
{
/// <summary>
/// Runs the class with the specified arguments.
/// </summary>
/// <param name = "_args">The specified arguments.</param>
public static void main(Args _args)
{
DMFEntity entities;
DictDataEntity dataEntity;
DictDataEntityField dataEntityField;
DictEnum dictEnum;
DictEnum dictEnumCategory = new SysDictEnum(enumNum(EntityCategory));
CommaTextStreamIo csv;
TableId tableId;
int i, j, enumValCnt, fieldCnt;
str enumValues;
try
{
csv = CommaTextStreamIo::constructForWrite();
csv.write(["ENTITY",
"NAME",
"PUBLIC",
"PUBLIC NAME",
"CATEGORY",
"SHARED",
"FIELD NAME",
"FIELD LABEL",
"FIELD TYPE",
"ENUM VALUES",
"MANDATORY",
"FOREIGN KEY",
"ALLOW EDIT",
"ALLOW EDIT ON CREATE",
"ORIGIN FIELD",
"ORIGIN TABLE"
]);
while select entities
where entities.EntityIsEnabled == NoYes::Yes
&& entities.TargetEntity != ""
&& entities.EntityType == DMFEntityTypes::Entity
{
tableId = tableName2Id(entities.TargetEntity);
if (tableId == 0)
{
continue;
}
dataEntity = new DictDataEntity(tableId);
fieldCnt = dataEntity.fieldCnt();
for (i=1; i <= fieldCnt; i++)
{
dataEntityField = new DictDataEntityField(tableId, dataEntity.fieldCnt2Id(i));
if (dataEntityField.isSystem())
{
continue;
}
if (dataEntityField.baseType() == Types::Enum)
{
dictEnum = new DictEnum(dataEntityField.enumId());
enumValCnt = dictEnum.values();
enumValues = "";
for (j=0; j < enumValCnt; j++)
{
if (strLen(enumValues) > 0)
{
enumValues = enumValues + " | ";
}
enumValues = enumValues +
strFmt("%1-%2",
dictEnum.index2Value(j),
dictEnum.index2Label(j) ? dictEnum.index2Label(j) : dictEnum.index2Symbol(j));
}
}
csv.write([dataEntity.name(),
dataEntity.label(),
dataEntity.isPublic() ? "Yes" : "No",
dataEntity.publicEntityName(),
dictEnumCategory.value2Label(dataEntity.entityCategory()),
dataEntity.dataPrCompany() ? 'No' : "Yes",
dataEntityField.name(),
dataEntityField.label(),
dataEntityField.baseType() == Types::String ?
strFmt("%1 (%2)", dataEntityField.baseType(), dataEntityField.stringLen()) :
strFmt("%1", dataEntityField.baseType()),
dataEntityField.baseType() == Types::Enum ? enumValues : "",
dataEntityField.mandatory() ? "Yes" : "No",
dataEntityField.isSurrogateForeignKey() ? "Yes" : "No",
dataEntityField.allowEdit() ? "Yes" : "No",
dataEntityField.allowEditOnCreate() ? "Yes" : "No",
dataEntityField.dataField(),
dataEntityField.dataSource()
]);
}
}
}
catch
{
info(CLRInterop::getLastException().toString());
}
File::SendFileToUser(csv.getStream(), "DataEntitiesMetadataExport.csv");
}
}