Search in sources :

Example 1 with IAuditManager

use of org.apache.hop.history.IAuditManager in project hop by apache.

the class AuditManagerGuiUtil method addLastUsedValue.

public static final void addLastUsedValue(String type, String value) {
    if (StringUtil.isEmpty(value)) {
        // Not storing empty values
        return;
    }
    IAuditManager auditManager = AuditManager.getActive();
    try {
        AuditList list = auditManager.retrieveList(HopNamespace.getNamespace(), type);
        if (list == null) {
            list = new AuditList();
        }
        List<String> names = list.getNames();
        // Move the value to the start of the list if it exists
        // 
        int index = names.indexOf(value);
        if (index >= 0) {
            names.remove(index);
        }
        names.add(0, value);
        // 
        while (list.getNames().size() > 50) {
            list.getNames().remove(list.getNames().size() - 1);
        }
        auditManager.storeList(HopNamespace.getNamespace(), type, list);
    } catch (Exception e) {
        LogChannel.UI.logError("Unable to store list using audit manager with type: " + type + " in group " + HopNamespace.getNamespace(), e);
    }
}
Also used : IAuditManager(org.apache.hop.history.IAuditManager) AuditList(org.apache.hop.history.AuditList)

Aggregations

AuditList (org.apache.hop.history.AuditList)1 IAuditManager (org.apache.hop.history.IAuditManager)1