Search in sources :

Example 11 with DashboardElement

use of org.netxms.client.dashboards.DashboardElement in project netxms by netxms.

the class ImportDashboard method doIdMapping.

/**
 * Map node and DCI ID from source system to destination system
 * @throws Exception
 * @return true if import operation should continue
 */
private boolean doIdMapping(final Display display, final NXCSession session, List<DashboardElement> dashboardElements, Element root) throws Exception {
    final Map<Long, ObjectIdMatchingData> objects = readSourceObjects(root);
    final Map<Long, DciIdMatchingData> dcis = readSourceDci(root);
    // add all node IDs from DCI list if they are missing
    for (DciIdMatchingData d : dcis.values()) {
        if (!objects.containsKey(d.srcNodeId))
            // $NON-NLS-1$
            objects.put(d.srcNodeId, new ObjectIdMatchingData(d.srcNodeId, "", AbstractObject.OBJECT_NODE));
    }
    // try to match objects
    for (ObjectIdMatchingData d : objects.values()) {
        if (d.srcId < 10) {
            // built-in object
            d.dstId = d.srcId;
            continue;
        }
        if (d.srcName.isEmpty())
            continue;
        AbstractObject object = session.findObjectByName(d.srcName);
        if ((object != null) && isCompatibleClasses(object.getObjectClass(), d.objectClass)) {
            d.dstId = object.getObjectId();
            d.dstName = object.getObjectName();
        }
    }
    // try to match DCIs
    for (DciIdMatchingData d : dcis.values()) {
        // get node ID on target system
        ObjectIdMatchingData od = objects.get(d.srcNodeId);
        // bind DCI data to appropriate node data
        od.dcis.add(d);
        if (od.dstId == 0)
            // no match for node
            continue;
        d.dstNodeId = od.dstId;
        DciValue[] dciValues = session.getLastValues(d.dstNodeId);
        for (DciValue v : dciValues) {
            if (v.getDescription().equalsIgnoreCase(d.srcName)) {
                d.dstDciId = v.getId();
                d.dstName = v.getDescription();
                break;
            }
        }
    }
    // show matching results to user
    UIJob job = new // $NON-NLS-1$
    UIJob(// $NON-NLS-1$
    display, // $NON-NLS-1$
    "") {

        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
            IdMatchingDialog dlg = new IdMatchingDialog(window.getShell(), objects, dcis);
            return (dlg.open() == Window.OK) ? Status.OK_STATUS : Status.CANCEL_STATUS;
        }
    };
    job.schedule();
    job.join();
    if (job.getResult().equals(Status.OK_STATUS)) {
        // update dashboard elements with mapping data
        for (DashboardElement e : dashboardElements) updateDashboardElement(e, objects, dcis);
        return true;
    }
    return false;
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IdMatchingDialog(org.netxms.ui.eclipse.dashboard.dialogs.IdMatchingDialog) ObjectIdMatchingData(org.netxms.ui.eclipse.dashboard.dialogs.helpers.ObjectIdMatchingData) AbstractObject(org.netxms.client.objects.AbstractObject) DciValue(org.netxms.client.datacollection.DciValue) UIJob(org.eclipse.ui.progress.UIJob) DciIdMatchingData(org.netxms.ui.eclipse.dashboard.dialogs.helpers.DciIdMatchingData) DashboardElement(org.netxms.client.dashboards.DashboardElement)

Example 12 with DashboardElement

use of org.netxms.client.dashboards.DashboardElement in project netxms by netxms.

the class NXCSession method modifyObject.

/**
 * Modify object (generic interface, in most cases wrapper functions should
 * be used instead).
 *
 * @param data     Object modification data
 * @param userData user-defined data for custom object modification
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public void modifyObject(final NXCObjectModificationData data, final Object userData) throws IOException, NXCException {
    NXCPMessage msg = newMessage(NXCPCodes.CMD_MODIFY_OBJECT);
    msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) data.getObjectId());
    // Object name
    if (data.isFieldSet(NXCObjectModificationData.NAME)) {
        msg.setField(NXCPCodes.VID_OBJECT_NAME, data.getName());
    }
    // Primary IP
    if (data.isFieldSet(NXCObjectModificationData.PRIMARY_IP)) {
        msg.setField(NXCPCodes.VID_IP_ADDRESS, data.getPrimaryIpAddress());
    }
    // Access control list
    if (data.isFieldSet(NXCObjectModificationData.ACL)) {
        final AccessListElement[] acl = data.getACL();
        msg.setFieldInt32(NXCPCodes.VID_ACL_SIZE, acl.length);
        msg.setFieldInt16(NXCPCodes.VID_INHERIT_RIGHTS, data.isInheritAccessRights() ? 1 : 0);
        long id1 = NXCPCodes.VID_ACL_USER_BASE;
        long id2 = NXCPCodes.VID_ACL_RIGHTS_BASE;
        for (int i = 0; i < acl.length; i++) {
            msg.setFieldInt32(id1++, (int) acl[i].getUserId());
            msg.setFieldInt32(id2++, acl[i].getAccessRights());
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.CUSTOM_ATTRIBUTES)) {
        Map<String, String> attrList = data.getCustomAttributes();
        Iterator<String> it = attrList.keySet().iterator();
        long id = NXCPCodes.VID_CUSTOM_ATTRIBUTES_BASE;
        int count = 0;
        while (it.hasNext()) {
            String key = it.next();
            String value = attrList.get(key);
            msg.setField(id++, key);
            msg.setField(id++, value);
            count++;
        }
        msg.setFieldInt32(NXCPCodes.VID_NUM_CUSTOM_ATTRIBUTES, count);
    }
    if (data.isFieldSet(NXCObjectModificationData.AUTOBIND_FILTER)) {
        msg.setField(NXCPCodes.VID_AUTOBIND_FILTER, data.getAutoBindFilter());
    }
    if (data.isFieldSet(NXCObjectModificationData.FILTER)) {
        msg.setField(NXCPCodes.VID_FILTER, data.getFilter());
    }
    if (data.isFieldSet(NXCObjectModificationData.DESCRIPTION)) {
        msg.setField(NXCPCodes.VID_DESCRIPTION, data.getDescription());
    }
    if (data.isFieldSet(NXCObjectModificationData.VERSION)) {
        msg.setFieldInt32(NXCPCodes.VID_VERSION, data.getVersion());
    }
    // Configuration file
    if (data.isFieldSet(NXCObjectModificationData.POLICY_CONFIG)) {
        msg.setField(NXCPCodes.VID_CONFIG_FILE_DATA, data.getConfigFileContent());
    }
    if (data.isFieldSet(NXCObjectModificationData.AGENT_PORT)) {
        msg.setFieldInt16(NXCPCodes.VID_AGENT_PORT, data.getAgentPort());
    }
    if (data.isFieldSet(NXCObjectModificationData.AGENT_PROXY)) {
        msg.setFieldInt32(NXCPCodes.VID_AGENT_PROXY, (int) data.getAgentProxy());
    }
    if (data.isFieldSet(NXCObjectModificationData.AGENT_AUTH)) {
        msg.setFieldInt16(NXCPCodes.VID_AUTH_METHOD, data.getAgentAuthMethod());
        msg.setField(NXCPCodes.VID_SHARED_SECRET, data.getAgentSecret());
    }
    if (data.isFieldSet(NXCObjectModificationData.TRUSTED_NODES)) {
        final long[] nodes = data.getTrustedNodes();
        msg.setFieldInt32(NXCPCodes.VID_NUM_TRUSTED_NODES, nodes.length);
        msg.setField(NXCPCodes.VID_TRUSTED_NODES, nodes);
    }
    if (data.isFieldSet(NXCObjectModificationData.SNMP_VERSION)) {
        msg.setFieldInt16(NXCPCodes.VID_SNMP_VERSION, data.getSnmpVersion());
    }
    if (data.isFieldSet(NXCObjectModificationData.SNMP_AUTH)) {
        msg.setField(NXCPCodes.VID_SNMP_AUTH_OBJECT, data.getSnmpAuthName());
        msg.setField(NXCPCodes.VID_SNMP_AUTH_PASSWORD, data.getSnmpAuthPassword());
        msg.setField(NXCPCodes.VID_SNMP_PRIV_PASSWORD, data.getSnmpPrivPassword());
        int methods = data.getSnmpAuthMethod() | (data.getSnmpPrivMethod() << 8);
        msg.setFieldInt16(NXCPCodes.VID_SNMP_USM_METHODS, methods);
    }
    if (data.isFieldSet(NXCObjectModificationData.SNMP_PROXY)) {
        msg.setFieldInt32(NXCPCodes.VID_SNMP_PROXY, (int) data.getSnmpProxy());
    }
    if (data.isFieldSet(NXCObjectModificationData.SNMP_PORT)) {
        msg.setFieldInt16(NXCPCodes.VID_SNMP_PORT, data.getSnmpPort());
    }
    if (data.isFieldSet(NXCObjectModificationData.ICMP_PROXY)) {
        msg.setFieldInt32(NXCPCodes.VID_ICMP_PROXY, (int) data.getIcmpProxy());
    }
    if (data.isFieldSet(NXCObjectModificationData.GEOLOCATION)) {
        final GeoLocation gl = data.getGeolocation();
        msg.setFieldInt16(NXCPCodes.VID_GEOLOCATION_TYPE, gl.getType());
        msg.setField(NXCPCodes.VID_LATITUDE, gl.getLatitude());
        msg.setField(NXCPCodes.VID_LONGITUDE, gl.getLongitude());
        msg.setFieldInt16(NXCPCodes.VID_ACCURACY, gl.getAccuracy());
        if (gl.getTimestamp() != null) {
            msg.setFieldInt64(NXCPCodes.VID_GEOLOCATION_TIMESTAMP, gl.getTimestamp().getTime() / 1000);
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.MAP_LAYOUT)) {
        msg.setFieldInt16(NXCPCodes.VID_LAYOUT, data.getMapLayout().getValue());
    }
    if (data.isFieldSet(NXCObjectModificationData.MAP_BACKGROUND)) {
        msg.setField(NXCPCodes.VID_BACKGROUND, data.getMapBackground());
        msg.setField(NXCPCodes.VID_BACKGROUND_LATITUDE, data.getMapBackgroundLocation().getLatitude());
        msg.setField(NXCPCodes.VID_BACKGROUND_LONGITUDE, data.getMapBackgroundLocation().getLongitude());
        msg.setFieldInt16(NXCPCodes.VID_BACKGROUND_ZOOM, data.getMapBackgroundZoom());
        msg.setFieldInt32(NXCPCodes.VID_BACKGROUND_COLOR, data.getMapBackgroundColor());
    }
    if (data.isFieldSet(NXCObjectModificationData.IMAGE)) {
        msg.setField(NXCPCodes.VID_IMAGE, data.getImage());
    }
    if (data.isFieldSet(NXCObjectModificationData.MAP_CONTENT)) {
        msg.setFieldInt32(NXCPCodes.VID_NUM_ELEMENTS, data.getMapElements().size());
        long varId = NXCPCodes.VID_ELEMENT_LIST_BASE;
        for (NetworkMapElement e : data.getMapElements()) {
            e.fillMessage(msg, varId);
            varId += 100;
        }
        msg.setFieldInt32(NXCPCodes.VID_NUM_LINKS, data.getMapLinks().size());
        varId = NXCPCodes.VID_LINK_LIST_BASE;
        for (NetworkMapLink l : data.getMapLinks()) {
            l.fillMessage(msg, varId);
            varId += 20;
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.COLUMN_COUNT)) {
        msg.setFieldInt16(NXCPCodes.VID_NUM_COLUMNS, data.getColumnCount());
    }
    if (data.isFieldSet(NXCObjectModificationData.DASHBOARD_ELEMENTS)) {
        msg.setFieldInt32(NXCPCodes.VID_NUM_ELEMENTS, data.getDashboardElements().size());
        long varId = NXCPCodes.VID_ELEMENT_LIST_BASE;
        for (DashboardElement e : data.getDashboardElements()) {
            e.fillMessage(msg, varId);
            varId += 10;
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.URL_LIST)) {
        msg.setFieldInt32(NXCPCodes.VID_NUM_URLS, data.getUrls().size());
        long fieldId = NXCPCodes.VID_URL_LIST_BASE;
        for (ObjectUrl u : data.getUrls()) {
            u.fillMessage(msg, fieldId);
            fieldId += 10;
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.SCRIPT)) {
        msg.setField(NXCPCodes.VID_SCRIPT, data.getScript());
    }
    if (data.isFieldSet(NXCObjectModificationData.ACTIVATION_EVENT)) {
        msg.setFieldInt32(NXCPCodes.VID_ACTIVATION_EVENT, data.getActivationEvent());
    }
    if (data.isFieldSet(NXCObjectModificationData.DEACTIVATION_EVENT)) {
        msg.setFieldInt32(NXCPCodes.VID_DEACTIVATION_EVENT, data.getDeactivationEvent());
    }
    if (data.isFieldSet(NXCObjectModificationData.SOURCE_OBJECT)) {
        msg.setFieldInt32(NXCPCodes.VID_SOURCE_OBJECT, (int) data.getSourceObject());
    }
    if (data.isFieldSet(NXCObjectModificationData.ACTIVE_STATUS)) {
        msg.setFieldInt16(NXCPCodes.VID_ACTIVE_STATUS, data.getActiveStatus());
    }
    if (data.isFieldSet(NXCObjectModificationData.INACTIVE_STATUS)) {
        msg.setFieldInt16(NXCPCodes.VID_INACTIVE_STATUS, data.getInactiveStatus());
    }
    if (data.isFieldSet(NXCObjectModificationData.DCI_LIST)) {
        List<ConditionDciInfo> dciList = data.getDciList();
        msg.setFieldInt32(NXCPCodes.VID_NUM_ITEMS, dciList.size());
        long varId = NXCPCodes.VID_DCI_LIST_BASE;
        for (ConditionDciInfo dci : dciList) {
            msg.setFieldInt32(varId++, (int) dci.getDciId());
            msg.setFieldInt32(varId++, (int) dci.getNodeId());
            msg.setFieldInt16(varId++, dci.getFunction());
            msg.setFieldInt16(varId++, dci.getPolls());
            varId += 6;
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.DRILL_DOWN_OBJECT_ID)) {
        msg.setFieldInt32(NXCPCodes.VID_DRILL_DOWN_OBJECT_ID, (int) data.getDrillDownObjectId());
    }
    if (data.isFieldSet(NXCObjectModificationData.SERVICE_TYPE)) {
        msg.setFieldInt16(NXCPCodes.VID_SERVICE_TYPE, data.getServiceType());
    }
    if (data.isFieldSet(NXCObjectModificationData.IP_ADDRESS)) {
        msg.setField(NXCPCodes.VID_IP_ADDRESS, data.getIpAddress());
    }
    if (data.isFieldSet(NXCObjectModificationData.IP_PROTOCOL)) {
        msg.setFieldInt16(NXCPCodes.VID_IP_PROTO, data.getIpProtocol());
    }
    if (data.isFieldSet(NXCObjectModificationData.IP_PORT)) {
        msg.setFieldInt16(NXCPCodes.VID_IP_PORT, data.getIpPort());
    }
    if (data.isFieldSet(NXCObjectModificationData.POLLER_NODE)) {
        msg.setFieldInt32(NXCPCodes.VID_POLLER_NODE_ID, (int) data.getPollerNode());
    }
    if (data.isFieldSet(NXCObjectModificationData.REQUIRED_POLLS)) {
        msg.setFieldInt16(NXCPCodes.VID_REQUIRED_POLLS, data.getRequiredPolls());
    }
    if (data.isFieldSet(NXCObjectModificationData.REQUEST)) {
        msg.setField(NXCPCodes.VID_SERVICE_REQUEST, data.getRequest());
    }
    if (data.isFieldSet(NXCObjectModificationData.RESPONSE)) {
        msg.setField(NXCPCodes.VID_SERVICE_RESPONSE, data.getResponse());
    }
    if (data.isFieldSet(NXCObjectModificationData.OBJECT_FLAGS)) {
        msg.setFieldInt32(NXCPCodes.VID_FLAGS, data.getObjectFlags());
        msg.setFieldInt32(NXCPCodes.VID_FLAGS_MASK, data.getObjectFlagsMask());
    }
    if (data.isFieldSet(NXCObjectModificationData.IFXTABLE_POLICY)) {
        msg.setFieldInt16(NXCPCodes.VID_USE_IFXTABLE, data.getIfXTablePolicy());
    }
    if (data.isFieldSet(NXCObjectModificationData.REPORT_DEFINITION)) {
        msg.setField(NXCPCodes.VID_REPORT_DEFINITION, data.getReportDefinition());
    }
    if (data.isFieldSet(NXCObjectModificationData.CLUSTER_RESOURCES)) {
        msg.setFieldInt32(NXCPCodes.VID_NUM_RESOURCES, data.getResourceList().size());
        long varId = NXCPCodes.VID_RESOURCE_LIST_BASE;
        for (ClusterResource r : data.getResourceList()) {
            msg.setFieldInt32(varId++, (int) r.getId());
            msg.setField(varId++, r.getName());
            msg.setField(varId++, r.getVirtualAddress());
            varId += 7;
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.CLUSTER_NETWORKS)) {
        int count = data.getNetworkList().size();
        msg.setFieldInt32(NXCPCodes.VID_NUM_SYNC_SUBNETS, count);
        long varId = NXCPCodes.VID_SYNC_SUBNETS_BASE;
        for (InetAddressEx n : data.getNetworkList()) {
            msg.setField(varId++, n);
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.PRIMARY_NAME)) {
        msg.setField(NXCPCodes.VID_PRIMARY_NAME, data.getPrimaryName());
    }
    if (data.isFieldSet(NXCObjectModificationData.STATUS_CALCULATION)) {
        msg.setFieldInt16(NXCPCodes.VID_STATUS_CALCULATION_ALG, data.getStatusCalculationMethod());
        msg.setFieldInt16(NXCPCodes.VID_STATUS_PROPAGATION_ALG, data.getStatusPropagationMethod());
        msg.setFieldInt16(NXCPCodes.VID_FIXED_STATUS, data.getFixedPropagatedStatus().getValue());
        msg.setFieldInt16(NXCPCodes.VID_STATUS_SHIFT, data.getStatusShift());
        ObjectStatus[] transformation = data.getStatusTransformation();
        msg.setFieldInt16(NXCPCodes.VID_STATUS_TRANSLATION_1, transformation[0].getValue());
        msg.setFieldInt16(NXCPCodes.VID_STATUS_TRANSLATION_2, transformation[1].getValue());
        msg.setFieldInt16(NXCPCodes.VID_STATUS_TRANSLATION_3, transformation[2].getValue());
        msg.setFieldInt16(NXCPCodes.VID_STATUS_TRANSLATION_4, transformation[3].getValue());
        msg.setFieldInt16(NXCPCodes.VID_STATUS_SINGLE_THRESHOLD, data.getStatusSingleThreshold());
        int[] thresholds = data.getStatusThresholds();
        msg.setFieldInt16(NXCPCodes.VID_STATUS_THRESHOLD_1, thresholds[0]);
        msg.setFieldInt16(NXCPCodes.VID_STATUS_THRESHOLD_2, thresholds[1]);
        msg.setFieldInt16(NXCPCodes.VID_STATUS_THRESHOLD_3, thresholds[2]);
        msg.setFieldInt16(NXCPCodes.VID_STATUS_THRESHOLD_4, thresholds[3]);
    }
    if (data.isFieldSet(NXCObjectModificationData.EXPECTED_STATE)) {
        msg.setFieldInt16(NXCPCodes.VID_EXPECTED_STATE, data.getExpectedState());
    }
    if (data.isFieldSet(NXCObjectModificationData.LINK_COLOR)) {
        msg.setFieldInt32(NXCPCodes.VID_LINK_COLOR, data.getLinkColor());
    }
    if (data.isFieldSet(NXCObjectModificationData.CONNECTION_ROUTING)) {
        msg.setFieldInt16(NXCPCodes.VID_LINK_ROUTING, data.getConnectionRouting());
    }
    if (data.isFieldSet(NXCObjectModificationData.DISCOVERY_RADIUS)) {
        msg.setFieldInt32(NXCPCodes.VID_DISCOVERY_RADIUS, data.getDiscoveryRadius());
    }
    if (data.isFieldSet(NXCObjectModificationData.HEIGHT)) {
        msg.setFieldInt16(NXCPCodes.VID_HEIGHT, data.getHeight());
    }
    if (data.isFieldSet(NXCObjectModificationData.RACK_NUMB_SCHEME)) {
        msg.setField(NXCPCodes.VID_TOP_BOTTOM, data.isRackNumberingTopBottom());
    }
    if (data.isFieldSet(NXCObjectModificationData.PEER_GATEWAY)) {
        msg.setFieldInt32(NXCPCodes.VID_PEER_GATEWAY, (int) data.getPeerGatewayId());
    }
    if (data.isFieldSet(NXCObjectModificationData.VPN_NETWORKS)) {
        long fieldId = NXCPCodes.VID_VPN_NETWORK_BASE;
        msg.setFieldInt32(NXCPCodes.VID_NUM_LOCAL_NETS, data.getLocalNetworks().size());
        for (InetAddressEx a : data.getLocalNetworks()) {
            msg.setField(fieldId++, a);
        }
        msg.setFieldInt32(NXCPCodes.VID_NUM_REMOTE_NETS, data.getRemoteNetworks().size());
        for (InetAddressEx a : data.getRemoteNetworks()) {
            msg.setField(fieldId++, a);
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.POSTAL_ADDRESS)) {
        data.getPostalAddress().fillMessage(msg);
    }
    if (data.isFieldSet(NXCObjectModificationData.AGENT_CACHE_MODE)) {
        msg.setFieldInt16(NXCPCodes.VID_AGENT_CACHE_MODE, data.getAgentCacheMode().getValue());
    }
    if (data.isFieldSet(NXCObjectModificationData.AGENT_COMPRESSION_MODE)) {
        msg.setFieldInt16(NXCPCodes.VID_AGENT_COMPRESSION_MODE, data.getAgentCompressionMode().getValue());
    }
    if (data.isFieldSet(NXCObjectModificationData.MAPOBJ_DISP_MODE)) {
        msg.setFieldInt16(NXCPCodes.VID_DISPLAY_MODE, data.getMapObjectDisplayMode().getValue());
    }
    if (data.isFieldSet(NXCObjectModificationData.RACK_PLACEMENT)) {
        msg.setFieldInt32(NXCPCodes.VID_RACK_ID, (int) data.getRackId());
        msg.setField(NXCPCodes.VID_RACK_IMAGE_FRONT, data.getFrontRackImage());
        msg.setField(NXCPCodes.VID_RACK_IMAGE_REAR, data.getRearRackImage());
        msg.setFieldInt16(NXCPCodes.VID_RACK_POSITION, data.getRackPosition());
        msg.setFieldInt16(NXCPCodes.VID_RACK_HEIGHT, data.getRackHeight());
        msg.setFieldInt16(NXCPCodes.VID_RACK_ORIENTATION, data.getRackOrientation().getValue());
    }
    if (data.isFieldSet(NXCObjectModificationData.DASHBOARD_LIST)) {
        msg.setField(NXCPCodes.VID_DASHBOARDS, data.getDashboards());
    }
    if (data.isFieldSet(NXCObjectModificationData.CHASSIS_ID)) {
        msg.setFieldInt32(NXCPCodes.VID_CHASSIS_ID, (int) data.getChassisId());
    }
    if (data.isFieldSet(NXCObjectModificationData.CONTROLLER_ID)) {
        msg.setFieldInt32(NXCPCodes.VID_CONTROLLER_ID, (int) data.getControllerId());
    }
    if (data.isFieldSet(NXCObjectModificationData.SSH_PROXY)) {
        msg.setFieldInt32(NXCPCodes.VID_SSH_PROXY, (int) data.getSshProxy());
    }
    if (data.isFieldSet(NXCObjectModificationData.SSH_LOGIN)) {
        msg.setField(NXCPCodes.VID_SSH_LOGIN, data.getSshLogin());
    }
    if (data.isFieldSet(NXCObjectModificationData.SSH_PASSWORD)) {
        msg.setField(NXCPCodes.VID_SSH_PASSWORD, data.getSshPassword());
    }
    if (data.isFieldSet(NXCObjectModificationData.ZONE_PROXY)) {
        msg.setFieldInt32(NXCPCodes.VID_ZONE_PROXY, (int) data.getZoneProxy());
    }
    if (data.isFieldSet(NXCObjectModificationData.SEED_OBJECTS)) {
        msg.setField(NXCPCodes.VID_SEED_OBJECTS, data.getSeedObjectIds());
    }
    if (data.isFieldSet(NXCObjectModificationData.MAC_ADDRESS)) {
        msg.setField(NXCPCodes.VID_MAC_ADDR, data.getMacAddress());
    }
    if (data.isFieldSet(NXCObjectModificationData.DEVICE_CLASS)) {
        msg.setFieldInt32(NXCPCodes.VID_DEVICE_CLASS, data.getDeviceClass());
    }
    if (data.isFieldSet(NXCObjectModificationData.VENDOR)) {
        msg.setField(NXCPCodes.VID_VENDOR, data.getVendor());
    }
    if (data.isFieldSet(NXCObjectModificationData.SERIAL_NUMBER)) {
        msg.setField(NXCPCodes.VID_SERIAL_NUMBER, data.getSerialNumber());
    }
    if (data.isFieldSet(NXCObjectModificationData.DEVICE_ADDRESS)) {
        msg.setField(NXCPCodes.VID_DEVICE_ADDRESS, data.getDeviceAddress());
    }
    if (data.isFieldSet(NXCObjectModificationData.META_TYPE)) {
        msg.setField(NXCPCodes.VID_META_TYPE, data.getMetaType());
    }
    if (data.isFieldSet(NXCObjectModificationData.SENSOR_PROXY)) {
        msg.setFieldInt32(NXCPCodes.VID_SENSOR_PROXY, (int) data.getSensorProxy());
    }
    if (data.isFieldSet(NXCObjectModificationData.XML_CONFIG)) {
        msg.setField(NXCPCodes.VID_XML_CONFIG, data.getXmlConfig());
    }
    if (data.isFieldSet(NXCObjectModificationData.SNMP_PORT_LIST)) {
        msg.setFieldInt32(NXCPCodes.VID_ZONE_SNMP_PORT_COUNT, data.getSnmpPorts().size());
        for (int i = 0; i < data.getSnmpPorts().size(); i++) {
            msg.setField(NXCPCodes.VID_ZONE_SNMP_PORT_LIST_BASE + i, data.getSnmpPorts().get(i));
        }
    }
    if (data.isFieldSet(NXCObjectModificationData.PASSIVE_ELEMENTS)) {
        msg.setField(NXCPCodes.VID_PASSIVE_ELEMENTS, data.getPassiveElements());
    }
    if (data.isFieldSet(NXCObjectModificationData.RESPONSIBLE_USERS)) {
        Long[] users = data.getResponsibleUsers().toArray(new Long[data.getResponsibleUsers().size()]);
        msg.setField(NXCPCodes.VID_RESPONSIBLE_USERS, users);
    }
    modifyCustomObject(data, userData, msg);
    sendMessage(msg);
    waitForRCC(msg.getMessageId());
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage) ConditionDciInfo(org.netxms.client.datacollection.ConditionDciInfo) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) AccessPoint(org.netxms.client.objects.AccessPoint) DashboardElement(org.netxms.client.dashboards.DashboardElement) ClusterResource(org.netxms.client.objects.ClusterResource) ObjectStatus(org.netxms.client.constants.ObjectStatus) InetAddressEx(org.netxms.base.InetAddressEx) NetworkMapElement(org.netxms.client.maps.elements.NetworkMapElement) AtomicLong(java.util.concurrent.atomic.AtomicLong) GeoLocation(org.netxms.base.GeoLocation) NetworkMapLink(org.netxms.client.maps.NetworkMapLink)

Example 13 with DashboardElement

use of org.netxms.client.dashboards.DashboardElement in project netxms by netxms.

the class DashboardElements method addNewElement.

/**
 * Add new dashboard element
 */
private void addNewElement() {
    AddDashboardElementDlg dlg = new AddDashboardElementDlg(getShell());
    if (dlg.open() == Window.OK) {
        String config;
        switch(dlg.getElementType()) {
            case DashboardElement.BAR_CHART:
            case DashboardElement.PIE_CHART:
            case DashboardElement.TUBE_CHART:
                config = DashboardControl.DEFAULT_CHART_CONFIG;
                break;
            case DashboardElement.LINE_CHART:
                config = DashboardControl.DEFAULT_LINE_CHART_CONFIG;
                break;
            case DashboardElement.DIAL_CHART:
                config = DashboardControl.DEFAULT_DIAL_CHART_CONFIG;
                break;
            case DashboardElement.AVAILABLITY_CHART:
                config = DashboardControl.DEFAULT_AVAILABILITY_CHART_CONFIG;
                break;
            case DashboardElement.TABLE_BAR_CHART:
            case DashboardElement.TABLE_PIE_CHART:
            case DashboardElement.TABLE_TUBE_CHART:
                config = DashboardControl.DEFAULT_TABLE_CHART_CONFIG;
                break;
            case DashboardElement.LABEL:
                config = DashboardControl.DEFAULT_LABEL_CONFIG;
                break;
            case DashboardElement.ALARM_VIEWER:
            case DashboardElement.EVENT_MONITOR:
            case DashboardElement.SYSLOG_MONITOR:
            case DashboardElement.SNMP_TRAP_MONITOR:
            case DashboardElement.STATUS_INDICATOR:
            case DashboardElement.STATUS_MAP:
            case DashboardElement.DASHBOARD:
            case DashboardElement.RACK_DIAGRAM:
                config = DashboardControl.DEFAULT_OBJECT_REFERENCE_CONFIG;
                break;
            case DashboardElement.NETWORK_MAP:
            case DashboardElement.SERVICE_COMPONENTS:
                config = DashboardControl.DEFAULT_NETWORK_MAP_CONFIG;
                break;
            case DashboardElement.GEO_MAP:
                config = DashboardControl.DEFAULT_GEO_MAP_CONFIG;
                break;
            case DashboardElement.WEB_PAGE:
                config = DashboardControl.DEFAULT_WEB_PAGE_CONFIG;
                break;
            case DashboardElement.TABLE_VALUE:
                config = DashboardControl.DEFAULT_TABLE_VALUE_CONFIG;
                break;
            case DashboardElement.DCI_SUMMARY_TABLE:
                config = DashboardControl.DEFAULT_SUMMARY_TABLE_CONFIG;
                break;
            default:
                // $NON-NLS-1$
                config = "<element>\n</element>";
                break;
        }
        DashboardElement element = new DashboardElement(dlg.getElementType(), config);
        elements.add(element);
        viewer.setInput(elements.toArray());
        viewer.setSelection(new StructuredSelection(element));
    }
}
Also used : StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) AddDashboardElementDlg(org.netxms.ui.eclipse.dashboard.dialogs.AddDashboardElementDlg) DashboardElement(org.netxms.client.dashboards.DashboardElement)

Example 14 with DashboardElement

use of org.netxms.client.dashboards.DashboardElement in project netxms by netxms.

the class DashboardElements method moveDown.

/**
 * Move currently selected element down
 */
private void moveDown() {
    final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    if (selection.size() == 1) {
        DashboardElement element = (DashboardElement) selection.getFirstElement();
        int index = elements.indexOf(element);
        if ((index < elements.size() - 1) && (index >= 0)) {
            Collections.swap(elements, index + 1, index);
            viewer.setInput(elements.toArray());
            viewer.setSelection(new StructuredSelection(element));
        }
    }
}
Also used : StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DashboardElement(org.netxms.client.dashboards.DashboardElement)

Example 15 with DashboardElement

use of org.netxms.client.dashboards.DashboardElement in project netxms by netxms.

the class DashboardControl method addEventMonitor.

public void addEventMonitor() {
    DashboardElement e = new DashboardElement(DashboardElement.EVENT_MONITOR, DEFAULT_OBJECT_REFERENCE_CONFIG);
    addElement(e);
}
Also used : DashboardElement(org.netxms.client.dashboards.DashboardElement)

Aggregations

DashboardElement (org.netxms.client.dashboards.DashboardElement)23 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)5 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)3 NXCSession (org.netxms.client.NXCSession)3 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)3 NXCObjectModificationData (org.netxms.client.NXCObjectModificationData)2 AbstractObject (org.netxms.client.objects.AbstractObject)2 DashboardElementConfig (org.netxms.ui.eclipse.dashboard.widgets.internal.DashboardElementConfig)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Entry (java.util.Map.Entry)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1