Search in sources :

Example 6 with Template

use of org.netxms.client.objects.Template in project netxms by netxms.

the class ExportFileBuilder method doExport.

/**
 * Do export operation and call completion handler when done
 *
 * @param completionHandler
 */
private void doExport(final ExportCompletionHandler completionHandler) {
    final long[] eventList = new long[events.size()];
    int i = 0;
    for (EventObject o : events.values()) eventList[i++] = o.getCode();
    final long[] templateList = new long[templates.size()];
    i = 0;
    for (Template t : templates.values()) templateList[i++] = t.getObjectId();
    final long[] trapList = new long[traps.size()];
    i = 0;
    for (SnmpTrap t : traps.values()) trapList[i++] = t.getId();
    final UUID[] ruleList = new UUID[rules.size()];
    i = 0;
    for (EventProcessingPolicyRule r : rules.values()) ruleList[i++] = r.getGuid();
    final long[] scriptList = new long[scripts.size()];
    i = 0;
    for (Script s : scripts.values()) scriptList[i++] = s.getId();
    final long[] toolList = new long[tools.size()];
    i = 0;
    for (ObjectTool t : tools.values()) toolList[i++] = t.getId();
    final long[] summaryTableList = new long[summaryTables.size()];
    i = 0;
    for (DciSummaryTableDescriptor t : summaryTables.values()) summaryTableList[i++] = t.getId();
    final long[] actionList = new long[actions.size()];
    i = 0;
    for (ServerAction a : actions.values()) actionList[i++] = a.getId();
    final String descriptionText = description.getText();
    new ConsoleJob(Messages.get().ExportFileBuilder_ExportJobName, this, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final String xml = session.exportConfiguration(descriptionText, eventList, trapList, templateList, ruleList, scriptList, toolList, summaryTableList, actionList);
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    completionHandler.exportCompleted(xml);
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().ExportFileBuilder_ExportJobError;
        }
    }.start();
}
Also used : EventProcessingPolicyRule(org.netxms.client.events.EventProcessingPolicyRule) Script(org.netxms.client.Script) SnmpTrap(org.netxms.client.snmp.SnmpTrap) EventObject(org.netxms.client.events.EventObject) DciSummaryTableDescriptor(org.netxms.client.datacollection.DciSummaryTableDescriptor) Template(org.netxms.client.objects.Template) EventTemplate(org.netxms.client.events.EventTemplate) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) UUID(java.util.UUID) ServerAction(org.netxms.client.ServerAction) ObjectTool(org.netxms.client.objecttools.ObjectTool)

Example 7 with Template

use of org.netxms.client.objects.Template in project netxms by netxms.

the class ExportFileBuilder method addTemplates.

/**
 * Add templates to list
 */
private void addTemplates() {
    final ObjectSelectionDialog dlg = new ObjectSelectionDialog(getSite().getShell(), null, ObjectSelectionDialog.createTemplateSelectionFilter());
    dlg.enableMultiSelection(true);
    dlg.showFilterToolTip(false);
    if (dlg.open() == Window.OK) {
        final Set<Long> idList = new HashSet<Long>();
        for (AbstractObject o : dlg.getSelectedObjects()) {
            if (o instanceof TemplateGroup) {
                Set<AbstractObject> children = ((TemplateGroup) o).getAllChilds(AbstractObject.OBJECT_TEMPLATE);
                for (AbstractObject child : children) {
                    templates.put(((Template) child).getObjectId(), (Template) child);
                    idList.add(child.getObjectId());
                }
            } else if (o instanceof Template) {
                templates.put(((Template) o).getObjectId(), (Template) o);
                idList.add(o.getObjectId());
            }
        }
        templateViewer.setInput(templates.values().toArray());
        setModified();
        new ConsoleJob(Messages.get().ExportFileBuilder_ResolveJobName, this, Activator.PLUGIN_ID, null) {

            @Override
            protected void runInternal(IProgressMonitor monitor) throws Exception {
                final Set<Long> eventCodes = new HashSet<Long>();
                final Map<Long, Script> scriptList = new HashMap<Long, Script>();
                for (Long id : idList) {
                    long[] e = session.getDataCollectionEvents(id);
                    for (long c : e) {
                        if (c >= 100000)
                            eventCodes.add(c);
                    }
                    for (Script s : session.getDataCollectionScripts(id)) scriptList.put(s.getId(), s);
                }
                runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        for (EventObject e : session.findMultipleEventObjects(eventCodes.toArray(new Long[eventCodes.size()]))) {
                            events.put(e.getCode(), e);
                        }
                        eventViewer.setInput(events.values().toArray());
                        scripts.putAll(scriptList);
                        scriptViewer.setInput(scripts.values().toArray());
                    }
                });
            }

            @Override
            protected String getErrorMessage() {
                return null;
            }
        }.start();
    }
}
Also used : Script(org.netxms.client.Script) Set(java.util.Set) HashSet(java.util.HashSet) EventObject(org.netxms.client.events.EventObject) Template(org.netxms.client.objects.Template) EventTemplate(org.netxms.client.events.EventTemplate) ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TemplateGroup(org.netxms.client.objects.TemplateGroup) AbstractObject(org.netxms.client.objects.AbstractObject) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) Map(java.util.Map) HashMap(java.util.HashMap) HashSet(java.util.HashSet)

Example 8 with Template

use of org.netxms.client.objects.Template in project netxms by netxms.

the class NXCSession method createObjectFromMessage.

/**
 * Create object from message
 *
 * @param msg Source NXCP message
 * @return NetXMS object
 */
private AbstractObject createObjectFromMessage(NXCPMessage msg) {
    final int objectClass = msg.getFieldAsInt32(NXCPCodes.VID_OBJECT_CLASS);
    AbstractObject object = createCustomObjectFromMessage(objectClass, msg);
    if (object != null)
        return object;
    switch(objectClass) {
        case AbstractObject.OBJECT_ACCESSPOINT:
            object = new AccessPoint(msg, this);
            break;
        case AbstractObject.OBJECT_AGENTPOLICY:
            object = new AgentPolicy(msg, this);
            break;
        case AbstractObject.OBJECT_AGENTPOLICY_CONFIG:
            object = new AgentPolicyConfig(msg, this);
            break;
        case AbstractObject.OBJECT_AGENTPOLICY_LOGPARSER:
            object = new AgentPolicyLogParser(msg, this);
            break;
        case AbstractObject.OBJECT_BUSINESSSERVICE:
            object = new BusinessService(msg, this);
            break;
        case AbstractObject.OBJECT_BUSINESSSERVICEROOT:
            object = new BusinessServiceRoot(msg, this);
            break;
        case AbstractObject.OBJECT_CHASSIS:
            object = new Chassis(msg, this);
            break;
        case AbstractObject.OBJECT_CLUSTER:
            object = new Cluster(msg, this);
            break;
        case AbstractObject.OBJECT_CONDITION:
            object = new Condition(msg, this);
            break;
        case AbstractObject.OBJECT_CONTAINER:
            object = new Container(msg, this);
            break;
        case AbstractObject.OBJECT_DASHBOARDGROUP:
            object = new DashboardGroup(msg, this);
            break;
        case AbstractObject.OBJECT_DASHBOARD:
            object = new Dashboard(msg, this);
            break;
        case AbstractObject.OBJECT_DASHBOARDROOT:
            object = new DashboardRoot(msg, this);
            break;
        case AbstractObject.OBJECT_INTERFACE:
            object = new Interface(msg, this);
            break;
        case AbstractObject.OBJECT_MOBILEDEVICE:
            object = new MobileDevice(msg, this);
            break;
        case AbstractObject.OBJECT_NETWORK:
            object = new EntireNetwork(msg, this);
            break;
        case AbstractObject.OBJECT_NETWORKMAP:
            object = new NetworkMap(msg, this);
            break;
        case AbstractObject.OBJECT_NETWORKMAPGROUP:
            object = new NetworkMapGroup(msg, this);
            break;
        case AbstractObject.OBJECT_NETWORKMAPROOT:
            object = new NetworkMapRoot(msg, this);
            break;
        case AbstractObject.OBJECT_NETWORKSERVICE:
            object = new NetworkService(msg, this);
            break;
        case AbstractObject.OBJECT_NODE:
            object = new Node(msg, this);
            break;
        case AbstractObject.OBJECT_NODELINK:
            object = new NodeLink(msg, this);
            break;
        case AbstractObject.OBJECT_POLICYGROUP:
            object = new PolicyGroup(msg, this);
            break;
        case AbstractObject.OBJECT_POLICYROOT:
            object = new PolicyRoot(msg, this);
            break;
        case AbstractObject.OBJECT_RACK:
            object = new Rack(msg, this);
            break;
        case AbstractObject.OBJECT_SENSOR:
            object = new Sensor(msg, this);
            break;
        case AbstractObject.OBJECT_SERVICEROOT:
            object = new ServiceRoot(msg, this);
            break;
        case AbstractObject.OBJECT_SLMCHECK:
            object = new ServiceCheck(msg, this);
            break;
        case AbstractObject.OBJECT_SUBNET:
            object = new Subnet(msg, this);
            break;
        case AbstractObject.OBJECT_TEMPLATE:
            object = new Template(msg, this);
            break;
        case AbstractObject.OBJECT_TEMPLATEGROUP:
            object = new TemplateGroup(msg, this);
            break;
        case AbstractObject.OBJECT_TEMPLATEROOT:
            object = new TemplateRoot(msg, this);
            break;
        case AbstractObject.OBJECT_VPNCONNECTOR:
            object = new VPNConnector(msg, this);
            break;
        case AbstractObject.OBJECT_ZONE:
            object = new Zone(msg, this);
            break;
        default:
            object = new GenericObject(msg, this);
            break;
    }
    return object;
}
Also used : Chassis(org.netxms.client.objects.Chassis) DashboardGroup(org.netxms.client.objects.DashboardGroup) ServiceCheck(org.netxms.client.objects.ServiceCheck) TemplateRoot(org.netxms.client.objects.TemplateRoot) DashboardRoot(org.netxms.client.objects.DashboardRoot) AbstractNode(org.netxms.client.objects.AbstractNode) Node(org.netxms.client.objects.Node) NetworkMapGroup(org.netxms.client.objects.NetworkMapGroup) Dashboard(org.netxms.client.objects.Dashboard) AgentPolicyConfig(org.netxms.client.objects.AgentPolicyConfig) Template(org.netxms.client.objects.Template) Rack(org.netxms.client.objects.Rack) BusinessServiceRoot(org.netxms.client.objects.BusinessServiceRoot) Container(org.netxms.client.objects.Container) MobileDevice(org.netxms.client.objects.MobileDevice) TemplateGroup(org.netxms.client.objects.TemplateGroup) PolicyRoot(org.netxms.client.objects.PolicyRoot) Condition(org.netxms.client.objects.Condition) PolicyGroup(org.netxms.client.objects.PolicyGroup) Zone(org.netxms.client.objects.Zone) AccessPoint(org.netxms.client.objects.AccessPoint) VPNConnector(org.netxms.client.objects.VPNConnector) Cluster(org.netxms.client.objects.Cluster) NetworkMapRoot(org.netxms.client.objects.NetworkMapRoot) EntireNetwork(org.netxms.client.objects.EntireNetwork) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) AccessPoint(org.netxms.client.objects.AccessPoint) ServiceRoot(org.netxms.client.objects.ServiceRoot) BusinessServiceRoot(org.netxms.client.objects.BusinessServiceRoot) BusinessService(org.netxms.client.objects.BusinessService) AgentPolicy(org.netxms.client.objects.AgentPolicy) AbstractObject(org.netxms.client.objects.AbstractObject) GenericObject(org.netxms.client.objects.GenericObject) AgentPolicyLogParser(org.netxms.client.objects.AgentPolicyLogParser) NetworkService(org.netxms.client.objects.NetworkService) NodeLink(org.netxms.client.objects.NodeLink) Subnet(org.netxms.client.objects.Subnet) Interface(org.netxms.client.objects.Interface) NetworkMap(org.netxms.client.objects.NetworkMap) Sensor(org.netxms.client.objects.Sensor)

Example 9 with Template

use of org.netxms.client.objects.Template in project netxms by netxms.

the class ApplyTemplate method selectionChanged.

/**
 * @see IActionDelegate#selectionChanged(IAction, ISelection)
 */
public void selectionChanged(IAction action, ISelection selection) {
    if ((selection instanceof IStructuredSelection) && (((IStructuredSelection) selection).size() != 0)) {
        parentId = new ArrayList<Long>();
        for (Object s : ((IStructuredSelection) selection).toList()) {
            if (s instanceof Template) {
                action.setEnabled(true);
                parentId.add(((AbstractObject) s).getObjectId());
            }
        }
    } else {
        action.setEnabled(false);
        parentId = null;
    }
}
Also used : AbstractObject(org.netxms.client.objects.AbstractObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Template(org.netxms.client.objects.Template)

Example 10 with Template

use of org.netxms.client.objects.Template in project netxms by netxms.

the class RemoveTemplate method selectionChanged.

/* (non-Javadoc)
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
	 */
public void selectionChanged(IAction action, ISelection selection) {
    if ((selection instanceof IStructuredSelection) && (((IStructuredSelection) selection).size() == 1)) {
        Object obj = ((IStructuredSelection) selection).getFirstElement();
        if (obj instanceof Template) {
            action.setEnabled(true);
            parentId = ((AbstractObject) obj).getObjectId();
        } else {
            action.setEnabled(false);
            parentId = 0;
        }
    } else {
        action.setEnabled(false);
        parentId = 0;
    }
}
Also used : AbstractObject(org.netxms.client.objects.AbstractObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Template(org.netxms.client.objects.Template)

Aggregations

Template (org.netxms.client.objects.Template)14 AbstractObject (org.netxms.client.objects.AbstractObject)11 Cluster (org.netxms.client.objects.Cluster)5 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 AbstractNode (org.netxms.client.objects.AbstractNode)4 MobileDevice (org.netxms.client.objects.MobileDevice)4 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)4 ObjectSelectionDialog (org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog)4 DataCollectionObject (org.netxms.client.datacollection.DataCollectionObject)3 ArrayList (java.util.ArrayList)2 AgentParameter (org.netxms.client.AgentParameter)2 NXCSession (org.netxms.client.NXCSession)2 Script (org.netxms.client.Script)2 EventObject (org.netxms.client.events.EventObject)2 EventTemplate (org.netxms.client.events.EventTemplate)2 AgentPolicy (org.netxms.client.objects.AgentPolicy)2 BusinessService (org.netxms.client.objects.BusinessService)2 BusinessServiceRoot (org.netxms.client.objects.BusinessServiceRoot)2 Condition (org.netxms.client.objects.Condition)2