-
Notifications
You must be signed in to change notification settings - Fork 1
/
dmp-json.r
46 lines (46 loc) · 2.03 KB
/
dmp-json.r
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
jsonFileMeta {
# dmp-json.r
# Create a json file of all descriptive metadata for a file
# Write files into a separate metadata collection
#============ create a collection for reports if it does not exist ===============
checkCollInput (*Coll);
checkRescInput (*Res, $rodsZoneClient);
*LPath = "*Coll/Metadata";
isColl(*LPath, "stdout", *Status);
if (*Status >= 0) {
*Q1 = select DATA_NAME where COLL_NAME = '*Coll';
foreach (*R1 in *Q1) {
*File = *R1.DATA_NAME;
#============ create file into which results will be written =========================
*Lfile = "*LPath" ++ "/" ++ "*File" ++ ".json";
*Dfile = "destRescName=*Res++++forceFlag=";
msiDataObjCreate(*Lfile, *Dfile, *L_FD);
writeLine("*Lfile","\{");
writeLine("*Lfile"," \"DATA_NAME\"\: \"*File\"\,");
writeLine("*Lfile"," \"Metadata\"\: \[");
*Q3 = select count(META_DATA_ATTR_NAME) where DATA_NAME = '*File' and COLL_NAME = '*Coll';
foreach (*R3 in *Q3) {*Num = int(*R3.META_DATA_ATTR_NAME);}
*Count = 0;
*Q2 = select META_DATA_ATTR_NAME, META_DATA_ATTR_VALUE, META_DATA_ATTR_UNITS where DATA_NAME = '*File' and COLL_NAME = '*Coll';
foreach (*R2 in *Q2) {
*Name = *R2.META_DATA_ATTR_NAME;
*Value = *R2.META_DATA_ATTR_VALUE;
*Units = *R2.META_DATA_ATTR_UNITS;
*Count = *Count + 1;
writeLine("*Lfile"," \{");
writeLine("*Lfile"," \"META_DATA_ATTR_NAME\"\: \"*Name\"\,");
writeLine("*Lfile"," \"META_DATA_ATTR_VALUE\"\: \"*Value\"\,");
writeLine("*Lfile"," \"META_DATA_ATTR_UNITS\"\: \"*Units\"");
if (*Count == *Num) {writeLine("*Lfile"," \}")}
else {writeLine("*Lfile"," \}\,");}
}
writeLine("*Lfile"," \]");
writeLine("*Lfile","\}");
msiDataObjClose(*L_FD, *Status);
writeLine ("stdout", "Created JSON file for *Coll/*File");
}
writeLine ("stdout", "Finished processing collection *Coll");
}
}
INPUT *Coll = "/$rodsZoneClient/home/$userNameClient/stage", *Res = 'LTLResc'
OUTPUT ruleExecOut