Search in sources :

Example 1 with DciIdMatchingData

use of org.netxms.ui.eclipse.dashboard.dialogs.helpers.DciIdMatchingData in project netxms by netxms.

the class IdMatchingDialog method updateDciMapping.

/**
 * Update mapping for all DCIs of given node after node mapping change
 *
 * @param objData
 */
private void updateDciMapping(final ObjectIdMatchingData objData) {
    if (objData.dcis.size() == 0)
        return;
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().IdMatchingDialog_JobTitle, null, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final DciValue[] dciValues = session.getLastValues(objData.dstId);
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    for (DciIdMatchingData d : objData.dcis) {
                        d.dstNodeId = objData.dstId;
                        d.dstDciId = 0;
                        d.dstName = null;
                        for (DciValue v : dciValues) {
                            if (v.getDescription().equalsIgnoreCase(d.srcName)) {
                                d.dstDciId = v.getId();
                                d.dstName = v.getDescription();
                                break;
                            }
                        }
                    }
                    viewer.refresh(true);
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().IdMatchingDialog_JobErrorText;
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCSession(org.netxms.client.NXCSession) DciValue(org.netxms.client.datacollection.DciValue) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) DciIdMatchingData(org.netxms.ui.eclipse.dashboard.dialogs.helpers.DciIdMatchingData)

Example 2 with DciIdMatchingData

use of org.netxms.ui.eclipse.dashboard.dialogs.helpers.DciIdMatchingData in project netxms by netxms.

the class AbstractChartConfig method remapDataCollectionItems.

/* (non-Javadoc)
	 * @see org.netxms.ui.eclipse.dashboard.widgets.internal.DashboardElementConfig#remapDataCollectionItems(java.util.Map)
	 */
@Override
public void remapDataCollectionItems(Map<Long, DciIdMatchingData> remapData) {
    super.remapDataCollectionItems(remapData);
    for (ChartDciConfig dci : dciList) {
        DciIdMatchingData md = remapData.get(dci.dciId);
        if (md != null) {
            dci.dciId = md.dstDciId;
            dci.nodeId = md.dstNodeId;
        }
    }
}
Also used : ChartDciConfig(org.netxms.client.datacollection.ChartDciConfig) DciIdMatchingData(org.netxms.ui.eclipse.dashboard.dialogs.helpers.DciIdMatchingData)

Example 3 with DciIdMatchingData

use of org.netxms.ui.eclipse.dashboard.dialogs.helpers.DciIdMatchingData in project netxms by netxms.

the class TableComparisonChartConfig method remapDataCollectionItems.

/* (non-Javadoc)
    * @see org.netxms.ui.eclipse.dashboard.widgets.internal.DashboardElementConfig#remapDataCollectionItems(java.util.Map)
    */
@Override
public void remapDataCollectionItems(Map<Long, DciIdMatchingData> remapData) {
    super.remapDataCollectionItems(remapData);
    DciIdMatchingData md = remapData.get(dciId);
    if (md != null) {
        nodeId = md.dstNodeId;
        dciId = md.dstDciId;
    }
}
Also used : DciIdMatchingData(org.netxms.ui.eclipse.dashboard.dialogs.helpers.DciIdMatchingData)

Example 4 with DciIdMatchingData

use of org.netxms.ui.eclipse.dashboard.dialogs.helpers.DciIdMatchingData in project netxms by netxms.

the class TableValueConfig method remapDataCollectionItems.

/* (non-Javadoc)
    * @see org.netxms.ui.eclipse.dashboard.widgets.internal.DashboardElementConfig#remapDataCollectionItems(java.util.Map)
    */
@Override
public void remapDataCollectionItems(Map<Long, DciIdMatchingData> remapData) {
    super.remapDataCollectionItems(remapData);
    DciIdMatchingData md = remapData.get(dciId);
    if (md != null) {
        objectId = md.dstNodeId;
        dciId = md.dstDciId;
    }
}
Also used : DciIdMatchingData(org.netxms.ui.eclipse.dashboard.dialogs.helpers.DciIdMatchingData)

Example 5 with DciIdMatchingData

use of org.netxms.ui.eclipse.dashboard.dialogs.helpers.DciIdMatchingData 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)

Aggregations

DciIdMatchingData (org.netxms.ui.eclipse.dashboard.dialogs.helpers.DciIdMatchingData)7 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 DashboardElement (org.netxms.client.dashboards.DashboardElement)2 DciValue (org.netxms.client.datacollection.DciValue)2 ObjectIdMatchingData (org.netxms.ui.eclipse.dashboard.dialogs.helpers.ObjectIdMatchingData)2 HashMap (java.util.HashMap)1 UIJob (org.eclipse.ui.progress.UIJob)1 NXCSession (org.netxms.client.NXCSession)1 ChartDciConfig (org.netxms.client.datacollection.ChartDciConfig)1 AbstractObject (org.netxms.client.objects.AbstractObject)1 IdMatchingDialog (org.netxms.ui.eclipse.dashboard.dialogs.IdMatchingDialog)1 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)1 Element (org.w3c.dom.Element)1 NodeList (org.w3c.dom.NodeList)1