Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ class EntityDefinition {
if (internalEntityNode.attribute("no-update-stamp") != "true") {
// automatically add the lastUpdatedStamp field
internalEntityNode.append("field", [name:"lastUpdatedStamp", type:"date-time"])
internalEntityNode.append("field", [name:"createdStamp", type:"date-time"])
}

ArrayList<MNode> fieldNodeList = internalEntityNode.children("field")
Expand Down Expand Up @@ -431,6 +432,7 @@ class EntityDefinition {
String aliasName = fi.name
// never auto-alias these
if ("lastUpdatedStamp".equals(aliasName)) continue
if ("createdStamp".equals(aliasName)) continue
// if specified as excluded, leave it out
ArrayList<MNode> excludeList = aliasAll.children("exclude")
int excludeListSize = excludeList.size()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ public static class EntityInfo {

public final FieldInfo[] pkFieldInfoArray, nonPkFieldInfoArray, allFieldInfoArray;
final FieldInfo lastUpdatedStampInfo;
final FieldInfo createdStampInfo;
public final String allFieldsSqlSelect;
final Map<String, String> pkFieldDefaults, nonPkFieldDefaults;

Expand Down Expand Up @@ -362,7 +363,7 @@ public static class EntityInfo {
boolean hasFunctionAliasTemp = false;
Map<String, String> pkFieldDefaultsTemp = new HashMap<>();
Map<String, String> nonPkFieldDefaultsTemp = new HashMap<>();
FieldInfo lastUpdatedTemp = null;
FieldInfo lastUpdatedTemp = null, createdStampTemp = null;
for (int i = 0; i < allFieldInfoSize; i++) {
FieldInfo fi = allFieldInfoList.get(i);
allFieldInfoArray[i] = fi;
Expand All @@ -386,6 +387,8 @@ public static class EntityInfo {
else nonPkFieldDefaultsTemp.put(fi.name, defaultStr);
}
if ("lastUpdatedStamp".equals(fi.name)) lastUpdatedTemp = fi;
if ("createdStamp".equals(fi.name)) createdStampTemp = fi;

}
createOnlyFields = createOnlyFieldsTemp;
needsAuditLog = needsAuditLogTemp;
Expand All @@ -395,6 +398,7 @@ public static class EntityInfo {
pkFieldDefaults = pkFieldDefaultsTemp.size() > 0 ? pkFieldDefaultsTemp : null;
nonPkFieldDefaults = nonPkFieldDefaultsTemp.size() > 0 ? nonPkFieldDefaultsTemp : null;
lastUpdatedStampInfo = lastUpdatedTemp;
createdStampInfo = createdStampTemp;

pkFieldInfoArray = new FieldInfo[pkFieldInfoList.size()];
pkFieldInfoList.toArray(pkFieldInfoArray);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,7 @@ public long checkAgainstDatabaseInfo(List<Map<String, Object>> diffInfoList, Lis
for (String nonpkFieldName : this.getEntityDefinition().getNonPkFieldNames()) {
// skip the lastUpdatedStamp field
if ("lastUpdatedStamp".equals(nonpkFieldName)) continue;
if ("createdStamp".equals(nonpkFieldName)) continue;

final Object checkFieldValue = this.get(nonpkFieldName);
final Object dbFieldValue = dbValue.get(nonpkFieldName);
Expand Down Expand Up @@ -1035,6 +1036,7 @@ public long checkAgainstDatabase(List<String> messages) {
for (String nonpkFieldName : this.getEntityDefinition().getNonPkFieldNames()) {
// skip the lastUpdatedStamp field
if ("lastUpdatedStamp".equals(nonpkFieldName)) continue;
if ("createdStamp".equals(nonpkFieldName)) continue;

final Object checkFieldValue = this.get(nonpkFieldName);
final Object dbFieldValue = dbValue.get(nonpkFieldName);
Expand Down Expand Up @@ -1510,9 +1512,13 @@ public EntityValue create() {
final Long time = ecfi.transactionFacade.getCurrentTransactionStartTime();
Long lastUpdatedLong = time != null && time > 0 ? time : System.currentTimeMillis();
FieldInfo lastUpdatedStampInfo = ed.entityInfo.lastUpdatedStampInfo;
FieldInfo createdStampInfo = ed.entityInfo.createdStampInfo;
if (lastUpdatedStampInfo != null && valueMapInternal.getByIString(lastUpdatedStampInfo.name, lastUpdatedStampInfo.index) == null)
valueMapInternal.putByIString(lastUpdatedStampInfo.name, new Timestamp(lastUpdatedLong), lastUpdatedStampInfo.index);

if (createdStampInfo != null && valueMapInternal.getByIString(createdStampInfo.name, createdStampInfo.index) == null)
valueMapInternal.putByIString(createdStampInfo.name, new Timestamp(lastUpdatedLong), createdStampInfo.index);

// do the artifact push/authz
ArtifactExecutionInfoImpl aei = new ArtifactExecutionInfoImpl(entityName, ArtifactExecutionInfo.AT_ENTITY, ArtifactExecutionInfo.AUTHZA_CREATE, "create").setParameters(valueMapInternal);
aefi.pushInternal(aei, !entityInfo.authorizeSkipCreate, false);
Expand Down