Skip to content

Commit

Permalink
Merge pull request #122 from stevengreens10/fix
Browse files Browse the repository at this point in the history
Add file mapping and fix up some attributes
  • Loading branch information
CDaRip2U authored Apr 13, 2022
2 parents e92fd02 + 255b82e commit 5b42351
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAccessor;
import java.util.Date;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -354,24 +357,25 @@ private static InstanceProperties addPrimitivePropertyToInstance(OMRSRepositoryH
);
break;
case OM_PRIMITIVE_TYPE_DATE:
Date date;
if (propertyValue instanceof Date) {
resultingProperties = omrsRepositoryHelper.addDatePropertyToInstance(
sourceName,
properties,
propertyName,
(Date) propertyValue,
methodName
);
date = (Date) propertyValue;
} else if(propertyValue instanceof String && ((String)propertyValue).matches("\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.\\d{2,3}Z")) {
// Timestamp is ISO-8601
// https://stackoverflow.com/a/60214805
TemporalAccessor ta = DateTimeFormatter.ISO_INSTANT.parse((String) propertyValue);
date = Date.from(Instant.from(ta));
} else {
// Assume if not a date and not null, it is a numeric epoch timestamp
resultingProperties = omrsRepositoryHelper.addDatePropertyToInstance(
sourceName,
properties,
propertyName,
new Date((Long)propertyValue),
methodName
);
date = new Date((Long)propertyValue);
}

resultingProperties = omrsRepositoryHelper.addDatePropertyToInstance(
sourceName,
properties,
propertyName,
date,
methodName
);
break;
default:
log.error("Unhandled primitive type {} for {}", primitiveDef.getPrimitiveDefCategory(), propertyName);
Expand Down
116 changes: 78 additions & 38 deletions src/main/resources/TypeDefMappings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
"sasCat": "instance.name",
"omrs": "qualifiedName"
},
{
"sasCat": "instance.description",
"omrs": "description"
},
{
"sasCat": "attribute.creator",
"omrs": "owner"
Expand All @@ -26,28 +22,72 @@
]
},
{
"sasCat": "dataFlow",
"omrs": "Process",
"sasCat": "reference.file",
"omrs": "DataFile",
"propertyMappings": [
{
"sasCat": "instance.name",
"omrs": "name"
"omrs": "qualifiedName"
},
{
"sasCat": "instance.resourceId",
"omrs": "description"
},
{
"sasCat": "instance.id",
"omrs": "id"
"sasCat": "attribute.dateModified",
"omrs": "modifiedTime"
},
{
"sasCat": "attribute.dateCreated",
"omrs": "createTime"
}
]
},
{
"sasCat": "reference.decisionPythonFile",
"omrs": "DataFile",
"propertyMappings": [
{
"sasCat": "instance.name",
"omrs": "qualifiedName"
},
{
"sasCat": "instance.resourceId",
"omrs": "description"
},
{
"sasCat": "attribute.dateModified",
"omrs": "modifiedTime"
},
{
"sasCat": "attribute.dateCreated",
"omrs": "createTime"
},
{
"sasCat": "constant.Python code file",
"omrs": "fileType"
}
]
},
{
"sasCat": "dataFlow",
"omrs": "Process",
"propertyMappings": [
{
"sasCat": "instance.name",
"omrs": "qualifiedName"
},
{
"sasCat": "instance.resourceId",
"omrs": "description"
},
{
"sasCat": "attribute.creator",
"omrs": "author"
"omrs": "owner"
},
{
"sasCat": "attribute.editor",
"omrs": "modifier"
"sasCat": "attribute.dateModified",
"omrs": "latestChange"
}
]
},
Expand Down Expand Up @@ -328,24 +368,16 @@
"omrs": "qualifiedName"
},
{
"sasCat": "instance.id",
"omrs": "id"
"sasCat": "instance.resourceId",
"omrs": "description"
},
{
"sasCat": "attribute.creator",
"omrs": "author"
},
{
"sasCat": "attribute.dateCreated",
"omrs": "createdTime"
"omrs": "owner"
},
{
"sasCat": "attribute.dateModified",
"omrs": "lastModifiedTime"
},
{
"sasCat": "attribute.editor",
"omrs": "modifier"
"omrs": "latestChange"
}
]
},
Expand All @@ -358,24 +390,16 @@
"omrs": "qualifiedName"
},
{
"sasCat": "instance.id",
"omrs": "id"
"sasCat": "instance.resourceId",
"omrs": "description"
},
{
"sasCat": "attribute.creator",
"omrs": "author"
},
{
"sasCat": "attribute.dateCreated",
"omrs": "createdTime"
"omrs": "owner"
},
{
"sasCat": "attribute.dateModified",
"omrs": "lastModifiedTime"
},
{
"sasCat": "attribute.editor",
"omrs": "modifier"
"omrs": "latestChange"
}
]
},
Expand Down Expand Up @@ -481,6 +505,14 @@
"sasCat": "instance.id",
"omrs": "id"
},
{
"sasCat": "instance.description",
"omrs": "description"
},
{
"sasCat": "instance.resourceId",
"omrs": "url"
},
{
"sasCat": "attribute.creator",
"omrs": "author"
Expand All @@ -495,7 +527,7 @@
},
{
"sasCat": "attribute.editor",
"omrs": "modifier"
"omrs": "lastModifier"
}
]
},
Expand All @@ -511,6 +543,14 @@
"sasCat": "instance.id",
"omrs": "id"
},
{
"sasCat": "instance.description",
"omrs": "description"
},
{
"sasCat": "instance.resourceId",
"omrs": "url"
},
{
"sasCat": "attribute.creator",
"omrs": "author"
Expand All @@ -525,7 +565,7 @@
},
{
"sasCat": "attribute.editor",
"omrs": "modifier"
"omrs": "lastModifier"
}
]
},
Expand Down

0 comments on commit 5b42351

Please sign in to comment.