本文整理汇总了Java中org.ofbiz.entity.model.ModelField.getEnableAuditLog方法的典型用法代码示例。如果您正苦于以下问题:Java ModelField.getEnableAuditLog方法的具体用法?Java ModelField.getEnableAuditLog怎么用?Java ModelField.getEnableAuditLog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ofbiz.entity.model.ModelField
的用法示例。
在下文中一共展示了ModelField.getEnableAuditLog方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createEntityAuditLogAll
import org.ofbiz.entity.model.ModelField; //导入方法依赖的package包/类
protected void createEntityAuditLogAll(GenericValue value, boolean isUpdate, boolean isRemove) throws GenericEntityException {
Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
for (ModelField mf: value.getModelEntity().getFieldsUnmodifiable()) {
if (mf.getEnableAuditLog()) {
createEntityAuditLogSingle(value, mf, isUpdate, isRemove, nowTimestamp);
}
}
}
示例2: createEntityAuditLogSingle
import org.ofbiz.entity.model.ModelField; //导入方法依赖的package包/类
protected void createEntityAuditLogSingle(GenericValue value, ModelField mf, boolean isUpdate, boolean isRemove, Timestamp nowTimestamp) throws GenericEntityException {
if (value == null || mf == null || !mf.getEnableAuditLog() || this.testRollbackInProgress) {
return;
}
String newValueText = null;
String oldValueText = null;
GenericValue oldGv = null;
if (isUpdate) {
// it's an update, get it from the database
oldGv = this.findOne(value.getEntityName(), value.getPrimaryKey(), false);
} else if (isRemove) {
oldGv = value;
}
if (oldGv == null) {
if (isUpdate || isRemove) {
oldValueText = "[ERROR] Old value not found even though it was an update or remove";
}
} else {
// lookup old value
Object oldValue = oldGv.get(mf.getName());
if (oldValue != null) {
oldValueText = oldValue.toString();
if (oldValueText.length() > 250) {
oldValueText = oldValueText.substring(0, 250);
}
}
}
if (!isRemove) {
Object newValue = value.get(mf.getName());
if (newValue != null) {
newValueText = newValue.toString();
if (newValueText.length() > 250) {
newValueText = newValueText.substring(0, 250);
}
}
}
if (!(newValueText == null ? "" : newValueText).equals((oldValueText == null ? "" : oldValueText))) {
// only save changed values
GenericValue entityAuditLog = this.makeValue("EntityAuditLog");
entityAuditLog.set("auditHistorySeqId", this.getNextSeqId("EntityAuditLog"));
entityAuditLog.set("changedEntityName", value.getEntityName());
entityAuditLog.set("changedFieldName", mf.getName());
String pkCombinedValueText = value.getPkShortValueString();
if (pkCombinedValueText.length() > 250) {
// uh-oh, the string is too long!
pkCombinedValueText = pkCombinedValueText.substring(0, 250);
}
entityAuditLog.set("pkCombinedValueText", pkCombinedValueText);
entityAuditLog.set("newValueText", newValueText);
entityAuditLog.set("oldValueText", oldValueText);
entityAuditLog.set("changedDate", nowTimestamp);
entityAuditLog.set("changedByInfo", getCurrentUserIdentifier());
entityAuditLog.set("changedSessionInfo", getCurrentSessionIdentifier());
this.create(entityAuditLog);
}
}