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();
}
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();
}
}
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;
}
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;
}
}
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;
}
}
Aggregations