List of usage examples for org.apache.commons.chain.impl ContextBase ContextBase
public ContextBase()
From source file:bridge.toolkit.Controller.java
/** * @param args/*from w ww.ja va 2 s . c o m*/ */ public static void main(String[] args) { Controller loader = new Controller(); Catalog sampleCatalog = loader.createCatalog(); Command toolkit = sampleCatalog.getCommand("SCORM"); Context ctx = new ContextBase(); ctx.put(Keys.SCPM_FILE, args[0]); ctx.put(Keys.RESOURCE_PACKAGE, args[1]); try { if (args.length > 2) { if (args[2] != null && args[2].equalsIgnoreCase("-scormflash")) { toolkit = sampleCatalog.getCommand("SCORM"); ctx.put(Keys.OUTPUT_TYPE, null); } else if (args[2] != null && args[2].equalsIgnoreCase("-scormhtml")) { toolkit = sampleCatalog.getCommand("SCORM"); ctx.put(Keys.OUTPUT_TYPE, "SCORMHTML"); } else if (args.length > 2 && args[2] != null && (args[2].equalsIgnoreCase("-mobileCourse"))) { toolkit = sampleCatalog.getCommand("Mobile"); ctx.put(Keys.OUTPUT_TYPE, "mobileCourse"); } else if (args.length > 2 && args[2] != null && (args[2].equalsIgnoreCase("-mobilePerformanceSupport"))) { toolkit = sampleCatalog.getCommand("Mobile"); } else if (args[2] != null && args[2].equalsIgnoreCase("-pdfinstructor")) { toolkit = sampleCatalog.getCommand("PDF"); ctx.put(Keys.PDF_OUTPUT_OPTION, "-instructor"); } else if (args[2] != null && args[2].equalsIgnoreCase("-pdfstudent")) { toolkit = sampleCatalog.getCommand("PDF"); ctx.put(Keys.PDF_OUTPUT_OPTION, "-student"); } if (args.length > 3 && args[3] != null) { ctx.put(Keys.OUTPUT_DIRECTORY, args[3]); } } toolkit.execute(ctx); } catch (Exception e) { e.printStackTrace(); System.out.println(e.getCause().toString()); } }
From source file:com.sf.ddao.chain.CtxHelper.java
public static Context context(Object... argv) { Context res = new ContextBase(); String key = null;/*from ww w . j a v a2 s. c om*/ for (Object o : argv) { if (key == null) { key = (String) o; } else { //noinspection unchecked res.put(key, o); key = null; } } return res; }
From source file:bridge.toolkit.commands.PDFBuilderTest.java
public void setUp(String src) { ctx = new ContextBase(); ctx.put(Keys.SCPM_FILE, System.getProperty("user.dir") + File.separator + "examples\\bike_SCPM\\SMC-S1000DBIKE-06RT9-00001-00.xml"); //+ "test_files\\scpm_slim\\SMC-S1000DBIKE-06RT9-00001-00.xml"); File srcPath = new File(src); dstPath = new File(System.getProperty("user.dir") + File.separator + "test_files\\resMap"); CopyDirectory cd = new CopyDirectory(); try {/*w w w .java 2 s. c o m*/ cd.copyDirectory(srcPath, dstPath); File svn = new File(dstPath.getAbsolutePath() + File.separator + ".svn"); if (svn.exists()) { deleteDirectory(svn); } } catch (IOException e) { e.printStackTrace(); } ctx.put(Keys.RESOURCE_PACKAGE, dstPath.getAbsolutePath()); pdfBuilder = new PDFBuilder(); }
From source file:bridge.toolkit.commands.MobileBuilderTest.java
public void setUp(String src) { ctx = new ContextBase(); ctx.put(Keys.SCPM_FILE, System.getProperty("user.dir") + File.separator + "examples\\bike_SCPM\\SMC-S1000DBIKE-06RT9-00001-00.xml"); File srcPath = new File(src); dstPath = new File(System.getProperty("user.dir") + File.separator + "test_files\\resMap"); CopyDirectory cd = new CopyDirectory(); try {//from ww w. ja v a 2 s . co m cd.copyDirectory(srcPath, dstPath); File svn = new File(dstPath.getAbsolutePath() + File.separator + ".svn"); if (svn.exists()) { deleteDirectory(svn); } File mediaSvn = new File( dstPath.getAbsolutePath() + File.separator + "media" + File.separator + ".svn"); if (mediaSvn.exists()) { deleteDirectory(mediaSvn); } } catch (IOException e) { e.printStackTrace(); } ctx.put(Keys.RESOURCE_PACKAGE, dstPath.getAbsolutePath()); mobileBuilder = new MobileBuilder(); }
From source file:bridge.toolkit.commands.PostProcessTest.java
/** * @throws java.lang.Exception/*from w w w . ja v a 2s . co m*/ */ @Before public void setUp() throws Exception { ctx = new ContextBase(); parser = new XMLParser(); ctx.put(Keys.XML_SOURCE, parser.getDoc(new File(System.getProperty("user.dir") + File.separator + "test_files\\bike_imsmanifest_after_scobuilder.xml"))); String resources = System.getProperty("user.dir") + File.separator + "examples\\bike_resource_package"; File srcPath = new File(resources); tempRes = new File(System.getProperty("user.dir") + File.separator + "test_files\\tempRes"); CopyDirectory cd = new CopyDirectory(); try { cd.copyDirectory(srcPath, tempRes); File svn = new File(tempRes.getAbsolutePath() + File.separator + ".svn"); if (svn.exists()) { deleteDirectory(svn); } } catch (IOException e) { e.printStackTrace(); } ctx.put(Keys.RESOURCE_PACKAGE, tempRes.getAbsolutePath()); ContentPackageCreator cpc = new ContentPackageCreator((String) ctx.get(Keys.RESOURCE_PACKAGE)); File cpPackage = cpc.createPackage(); ctx.put(Keys.CP_PACKAGE, cpPackage); postProcess = new PostProcess(); }
From source file:bridge.toolkit.commands.S1000DConverterTest.java
/** * @throws java.lang.Exception/*from www . j a va 2s .co m*/ */ @Before public void setUp() throws Exception { ctx = new ContextBase(); parser = new XMLParser(); ctx.put(Keys.SCPM_FILE, System.getProperty("user.dir") + File.separator + "examples\\bike_SCPM_4.1\\SMC-S1000DBIKE-06RT9-00001-00.xml"); String resources = System.getProperty("user.dir") + File.separator + "examples\\bike_resource_package_4.1"; File srcPath = new File(resources); tempRes = new File(System.getProperty("user.dir") + File.separator + "test_files\\tempRes"); tempRes.mkdir(); CopyDirectory cd = new CopyDirectory(); try { cd.copyDirectory(srcPath, tempRes); File svn = new File(tempRes.getAbsolutePath() + File.separator + ".svn"); if (svn.exists()) { deleteDirectory(svn); } } catch (IOException e) { e.printStackTrace(); } ctx.put(Keys.RESOURCE_PACKAGE, tempRes.getAbsolutePath()); rb = new S1000DConverter(); }
From source file:bridge.toolkit.commands.PreProcessTest.java
/** * @throws java.lang.Exception/*from ww w .j a v a 2 s . c om*/ */ public void setUp(String src) { ctx = new ContextBase(); ctx.put(Keys.SCPM_FILE, System.getProperty("user.dir") + File.separator + "examples\\bike_SCPM\\SMC-S1000DBIKE-06RT9-00001-00.xml"); File srcPath = new File(src); dstPath = new File(System.getProperty("user.dir") + File.separator + "test_files\\resMap"); CopyDirectory cd = new CopyDirectory(); try { cd.copyDirectory(srcPath, dstPath); File svn = new File(dstPath.getAbsolutePath() + File.separator + ".svn"); if (svn.exists()) { deleteDirectory(svn); } } catch (IOException e) { e.printStackTrace(); } ctx.put(Keys.RESOURCE_PACKAGE, dstPath.getAbsolutePath()); preProcess = new PreProcess(); }
From source file:bridge.toolkit.commands.SCOBuilderTest.java
/** * @throws java.lang.Exception/*ww w . ja va2 s . com*/ */ @Before public void setUp() throws Exception { ctx = new ContextBase(); parser = new XMLParser(); ctx.put(Keys.SCPM_FILE, System.getProperty("user.dir") + File.separator + "examples\\bike_SCPM\\SMC-S1000DBIKE-06RT9-00001-00.xml"); ctx.put(Keys.XML_SOURCE, parser.getDoc(new File(System.getProperty("user.dir") + File.separator + "test_files\\bike_imsmanifest_after_preprocess.xml"))); ctx.put(Keys.URN_MAP, parser.getDoc(new File( System.getProperty("user.dir") + File.separator + "test_files\\bike_urn_resource_map.xml"))); String resources = System.getProperty("user.dir") + File.separator + "examples\\bike_resource_package"; File srcPath = new File(resources); tempRes = new File(System.getProperty("user.dir") + File.separator + "test_files\\tempRes"); CopyDirectory cd = new CopyDirectory(); try { cd.copyDirectory(srcPath, tempRes); File svn = new File(tempRes.getAbsolutePath() + File.separator + ".svn"); if (svn.exists()) { deleteDirectory(svn); } } catch (IOException e) { e.printStackTrace(); } ctx.put(Keys.RESOURCE_PACKAGE, tempRes.getAbsolutePath()); rb = new SCOBuilder(); }
From source file:com.netsteadfast.greenstep.base.chain.SimpleChain.java
public ChainResultObj getResultFromClass(Class<Command>[] clazz) throws Exception { Context context = new ContextBase(); return this.getResultFromClass(clazz, context); }
From source file:com.netsteadfast.greenstep.base.chain.SimpleChain.java
public ChainResultObj getResultFromResource(String commandName) throws Exception { Context context = new ContextBase(); return this.getResultFromResource(commandName, context); }