Search in sources :

Example 1 with ObjectMenuFilter

use of org.netxms.client.ObjectMenuFilter in project netxms by netxms.

the class GraphSettings method createGraphSettings.

/**
 * Create graph settings object from NXCP message
 *
 * @param msg NXCP message
 * @param baseId base variable id
 * @return The graph settings object
 */
public static GraphSettings createGraphSettings(final NXCPMessage msg, long baseId) {
    GraphSettings gs;
    try {
        gs = GraphSettings.createFromXml(msg.getFieldAsString(baseId + 4));
    } catch (Exception e) {
        gs = new GraphSettings();
        Logger.debug("GraphSettings.CreateGraphSettings", "Cannot parse ChartConfig XML", e);
    }
    gs.id = msg.getFieldAsInt64(baseId);
    gs.ownerId = msg.getFieldAsInt64(baseId + 1);
    gs.flags = (int) msg.getFieldAsInt64(baseId + 2);
    gs.name = msg.getFieldAsString(baseId + 3);
    try {
        gs.filter = ObjectMenuFilter.createFromXml(msg.getFieldAsString(baseId + 5));
    } catch (Exception e) {
        Logger.debug("GraphSettings.CreateGraphSettings", "Cannot parse ObjectMenuFilter XML: ", e);
        gs.filter = new ObjectMenuFilter();
    }
    String[] parts = gs.name.split("->");
    gs.shortName = (parts.length > 1) ? parts[parts.length - 1] : gs.name;
    // ACL size
    int count = msg.getFieldAsInt32(baseId + 6);
    long[] users = msg.getFieldAsUInt32Array(baseId + 7);
    long[] rights = msg.getFieldAsUInt32Array(baseId + 8);
    gs.accessList = new ArrayList<AccessListElement>(count);
    for (int i = 0; i < count; i++) {
        gs.accessList.add(new AccessListElement(users[i], (int) rights[i]));
    }
    return gs;
}
Also used : ObjectMenuFilter(org.netxms.client.ObjectMenuFilter) AccessListElement(org.netxms.client.AccessListElement)

Aggregations

AccessListElement (org.netxms.client.AccessListElement)1 ObjectMenuFilter (org.netxms.client.ObjectMenuFilter)1