@Override protected Commandline buildCommandline() { resetFileLists(); if (files != null) { addToCompileList(getSrc()); addToCompileList(getResource()); } modules = moduleset.getModules(); if (compileList.size() == 0 && modules.size() == 0) { log("Nothing to compile"); return null; } LazyHelper lazyTask = new LazyHelper(this) { @Override protected File getArtifactDir(Module module) { File outModuleDir = new File(getOut(), module.toVersionedDir().getPath()); return outModuleDir; } @Override protected FileFilter getArtifactFilter() { return ARTIFACT_FILTER; } @Override protected long getOldestArtifactTime(File file) { return file.lastModified(); } @Override protected long getArtifactFileTime(Module module, File file) { File moduleDir = getArtifactDir(module); String name = module.getName() + ((module.getVersion() != null) ? "-" + module.getVersion() : "") + ".js"; File jsFile = new File(moduleDir, name); if (jsFile.isFile()) { return jsFile.lastModified(); } else { return Long.MAX_VALUE; } } }; if (lazyTask.filterFiles(compileList) && lazyTask.filterModules(modules)) { log("Everything's up to date"); return null; } return super.buildCommandline(); }
/** Inicjalizacja servletu. Tutaj ładowane są wszystkie moduły oraz zdarzenia */ @Override public void init() throws ServletException { Config.getConf().setWorkingDir(getServletContext().getRealPath("/")); EventManager evm = EventManager.getInstance(); EventManager.autoloadEvents(); // moduly ModuleGet mg = new ModuleGet(); ModuleSet ms = new ModuleSet(); Module m = new WodaModule(); // 0 mg.put(m); ms.put(m); m = new RoletaModule(); // 1 mg.put(m); ms.put(m); m = new BramaModule(); // 2 mg.put(m); ms.put(m); m = new AlarmModule(); // 3 mg.put(m); ms.put(m); m = new OgrodModule(); // 4 mg.put(m); ms.put(m); m = new ModbusModule(); // 5 mg.put(m); ms.put(m); Thread t = new Thread( new Runnable() { @Override public void run() { AlarmModule alarm = new AlarmModule(); System.out.println("Załadowano."); boolean al = false; while (true) { if (alarm.getValue(2) > 0) { if (!al) { al = true; System.out.println("ALARM!!"); DBDevices dev = new DBDevices(); Vector<DatabaseObj> devices = dev.executeQuery(); List<String> ID = new ArrayList<String>(); for (DatabaseObj ob : devices) { ob.read(); ID.add(ob.get("reg_id")); System.out.println(ob.get("reg_id")); } Sender sender = new Sender(Config.getConf().get("GCM_DEV_KEY")); Message message = new Message.Builder().addData("event", "ALARM").build(); String id = "APA91bFw1nQZxq3DYGG1Vhwmz0ryR8UUUoR7GwttSEa9AHE_HzhARZWdgxwT9xxBM3TCusm0vpEKic0KcAb7urTYMfIpkmZ5Sx6M7L-nIuZQTDrzaRJkmhPZurXMT-aPAXfvwDdG6kiB"; try { if (!ID.isEmpty()) { MulticastResult r = sender.send(message, ID, 3000); System.out.println(r.toString()); } } catch (IOException e) { e .printStackTrace(); // To change body of catch statement use File | // Settings | File Templates. } } } else { al = false; } try { Thread.sleep(1000); } catch (InterruptedException e) { e .printStackTrace(); // To change body of catch statement use File | Settings // | File Templates. } } } }); t.start(); evm.registerEvent(mg); evm.registerEvent(ms); try { Class.forName("com.mysql.jdbc.Driver").getClass(); } catch (ClassNotFoundException e) { e.printStackTrace(); } }
public void init(Object context) { // load data into various data structures // TODO: load results from a data file instead of static list results = new Vector(); Hashtable h = new Hashtable(); h.put("date", "08/09/2015"); h.put("topics", "White-Green Kicks, Punches, Strikes"); h.put("score", "95%"); results.addElement(h); h = new Hashtable(); h.put("date", "07/15/2015"); h.put("topics", "Green Concepts, Punches, Strikes"); h.put("score", "100%"); results.addElement(h); h = new Hashtable(); h.put("date", "07/15/2015"); h.put("topics", "Green Concepts, Punches, Strikes"); h.put("score", "100%"); results.addElement(h); h = new Hashtable(); h.put("date", "07/15/2015"); h.put("topics", "Green Concepts, Punches, Strikes"); h.put("score", "100%"); results.addElement(h); h = new Hashtable(); h.put("date", "07/15/2015"); h.put("topics", "Green Concepts, Punches, Strikes"); h.put("score", "100%"); results.addElement(h); // manually load some test data for now moduleSet = new ModuleSet(); Category c; Testable t; Learnable l; Vector<Testable> qList; Module m = new Module( "white_to_yellow", "white_to_yellow.png", "White to Yellow", "Requirements for White Belts to earn their Yellow Belt", false); c = new Category("blocks", "blocks.png", "Blocks"); m.addCategory(c); t = new Testable("Which block is an outwards middle block?", null); t.addAnswer(true, "Soto-uke"); t.addAnswer(false, "Ucki-uke"); t.addAnswer(false, "Soto-uchi"); t.addAnswer(false, "Gedan-barai"); qList = new Vector<Testable>(); qList.addElement(t); l = new Learnable( true, true, "Soto-uke", "white_to_yellow", "blocks", new String[0], "", "An outwards Middle Block. The hand crosses horizontally in front of the body then swings up to a vertical position in front of the shoulder. The elbow should finish one fist away from the body", qList); c.addLearnable(l); moduleSet.addModule(m); String categoryID = "kicks", categoryIcon = "kicks.png", categoryName = "Kicks", question = "which kick strikes with the heel?", CorrectAnswer = "Yoko-Keage", answer2 = "O-uchi-mawashi-geri", answer3 = "Ushiro-geri", answer4 = "Fumi-komi", lName = "O-uchi-mawashi-geri", lModule = "white_to_yellow", mIcon = lModule + ".png", mName = "White to Yellow", lCategory = "blocks", lDescription = "A side-kick thrusting with the heel outwards. The kick starts from sagi-aski-dachi then the the hips must rotate thrusting the heel outwards as the foot rotates to horizontal."; boolean lTestable = true, lTrainable = true; String[] lImages = new String[0]; t = new Testable(question, null); t.addAnswer(true, CorrectAnswer); t.addAnswer(false, answer2); t.addAnswer(false, answer3); t.addAnswer(false, answer4); qList = new Vector<Testable>(); qList.add(t); Module modCheck = moduleSet.getModule(lModule); if (modCheck == null) { modCheck = new Module(lModule, mIcon, mName, "Module Description", false); moduleSet.addModule(modCheck); } if (!modCheck.hasCategory(categoryID)) { moduleSet .getModule(lModule) .addCategory(new Category(categoryID, categoryIcon, categoryName)); } moduleSet .getModule(lModule) .getCategory(categoryID) .addLearnable( new Learnable( lTrainable, lTestable, lName, lModule, lCategory, lImages, null, lDescription, qList)); // TODO: load all categories, modules and data from files }