当前位置: 首页>>代码示例>>Java>>正文


Java ModelField.getEnableAuditLog方法代码示例

本文整理汇总了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);
        }
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:9,代码来源:GenericDelegator.java

示例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);
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:62,代码来源:GenericDelegator.java


注:本文中的org.ofbiz.entity.model.ModelField.getEnableAuditLog方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。