Importing a network resource

The importing a network resource example shows how to import a previously created network resource.

This example builds on the creating a network resource example described in Creating a network resource. Use this example as a model for importing a network resource.

ApiSession session;
ResourceManager rMgr;
WorkflowManager wMgr;
Date startDate;//execution window start date/time
Date endDate;//execution window end date/time
NetworkResourceKey nrKey;
Boolean overrideFlag;//whether to override conflicts
.
.
.
//it is assumed the session has been established
rMgr = session.resourceManager();
wMgr = session.workflowManager();
.
.
.
//it is assumed the startDate and endDate defining the execution window
//for the work have been set
//a UOW requires some comment describing the work
String comment = "Re-Import Network Resource(s)";
//instantiate and populate a command
ImportConfigurationCommand cmd = rMgr.dataFactory().newImportConfigurationCommand();
//this command operates on a Collection of NetworkResourceKeys,
//even though you may only have one of them
//it is assumed the key has been established
ArrayList nrKeys = new ArrayList();
nrKeys.add(nrKey);
cmd.setKeys(nrKeys);
cmd.setComment(comment);
cmd.setMaxNumberOfErrors(-1);
cmd.validate();

//now instantiate and populate the Work object to submit
CommandWork work = wMgr.dataFactory().newCommandWork();
work.setCommand(cmd);
work.setExecutionWindowStartTime(startDate);
work.setExecutionWindowEndTime(endDate);
work.validate();
//finally submit the work
WorkKey workKey = wMgr.submit(work, overrideFlag);