public static void processParams(String s[]) { /**/ if (s[0].equals("DevData")) { if (s.length == 1) { Err.error("Need to explicitly specify a database"); } /* * Dangerous! */ if (s[1].equals(WombatConnectionEnum.PROD)) { Err.error("Cannot work with the " + WombatConnectionEnum.getFromName(s[1]) + " database"); } /**/ if (s.length == 2) { DataStoreFactory dataStoreFactory = new WombatDataStoreFactory(); dataStoreFactory.addConnection(WombatConnectionEnum.getFromName(s[1])); dataStore = dataStoreFactory.getEntityManagedDataStore(); } else { Err.error(); } dataStore.startTx(); List list = (List) dataStore.get(POJOWombatData.WORKER); update(list); dataStore.commitTx(); } else { Err.error("Unrecognised param " + s[0]); } }
private void populate() { DataStoreFactory dataStoreFactory = new WombatDataStoreFactory(); dataStoreFactory.addConnection(WombatConnectionEnum.SERVER_CAYENNE); dataStore = dataStoreFactory.getEntityManagedDataStore(); demoDataCayenne = CayenneWombatDemoData.getInstance(ORMTypeEnum.CAYENNE_SERVER, dataStore); dataStore.startTx(); demoDataCayenne.doPopulation(); populateFromDemoData(); if (!COMMIT_POPULATION) { dataStore.rollbackTx(); } else { dataStore.commitTx(); } }
/** Setup data so will give a full roster no matter which month, no matter what time */ private void populateFromDemoData() { SdzEntityManagerI pm = dataStore.getEM(); pm.registerPersistentAll(demoDataCayenne.newWorkers); pm.registerPersistentAll(demoDataCayenne.newBMs); pm.registerPersistentAll(demoDataCayenne.newRSs); pm.registerPersistentAll(demoDataCayenne.newUsers); pm.registerPersistentAll( demoDataCayenne.wombatLookups.get(WombatDomainLookupEnum.ALL_DAY_IN_WEEK)); pm.registerPersistentAll( demoDataCayenne.wombatLookups.get(WombatDomainLookupEnum.ALL_FLEXIBILITY)); pm.registerPersistentAll( demoDataCayenne.wombatLookups.get(WombatDomainLookupEnum.ALL_MONTH_IN_YEAR)); pm.registerPersistentAll( demoDataCayenne.wombatLookups.get(WombatDomainLookupEnum.ALL_INTERVAL)); pm.registerPersistentAll( demoDataCayenne.wombatLookups.get(WombatDomainLookupEnum.ALL_FLEXIBILITY)); pm.registerPersistentAll( demoDataCayenne.wombatLookups.get(WombatDomainLookupEnum.ALL_SENIORITY)); pm.registerPersistentAll(demoDataCayenne.wombatLookups.get(WombatDomainLookupEnum.ALL_SEX)); pm.registerPersistentAll( demoDataCayenne.wombatLookups.get(WombatDomainLookupEnum.ALL_WEEK_IN_MONTH)); pm.registerPersistentAll( demoDataCayenne.wombatLookups.get(WombatDomainLookupEnum.ALL_WHICH_SHIFT)); Err.pr( "Population complete, have added " + demoDataCayenne.newWorkers.size() + " Workers and " + demoDataCayenne.newRSs.size() + " RosterSlots and " + demoDataCayenne.newUsers.size() + " UserDetails and " + demoDataCayenne.wombatLookups.get(WombatDomainLookupEnum.ALL_SENIORITY).size() + " Seniorities and " + demoDataCayenne.newBMs.size() + " BuddyManagers to the database"); Print.prList( demoDataCayenne.wombatLookups.get(WombatDomainLookupEnum.ALL_SENIORITY), "seniorities"); }
private static void update(Collection list) { int timesFound = 0; Worker nullWorker = null; for (Iterator iter = list.iterator(); iter.hasNext(); ) { Worker vol = (Worker) iter.next(); if ( // ( // vol.getChristianName() != null && // vol.getChristianName().equals( "Bart") // ) || vol.equals(Worker.NULL)) { timesFound++; if (timesFound > 1) { Err.error("Should only be one NULL volunteer"); } nullWorker = vol; Err.pr("NULL vol have found is " + nullWorker); } } if (nullWorker == null) { Err.pr("Could not find a worker equal to NULL, so creating one"); nullWorker = new Worker(); } nullWorker.setDummy(true); Err.pr( JDONote.APPEARS_CONSTRUCTOR_NOT_CALLED, "Why have to do this - Worker's constructor s/do it"); if (nullWorker.getBelongsToGroup() != null) { Err.pr(JDONote.APPEARS_CONSTRUCTOR_NOT_CALLED, "appears Constructor was called"); } else { Err.pr(JDONote.APPEARS_CONSTRUCTOR_NOT_CALLED, "appears Constructor was NOT called"); } nullWorker.setBelongsToGroup(nullWorker); dataStore.getEM().registerPersistent(nullWorker); Err.pr("MADE A NULL WORKER, " + nullWorker); }