private void startIteration(String cursorString) { // if (cursorString == null) { // CSVEntry entry = CSVCache.getInstance().getCSV(csvId); // if (entry != null) { // if (entry.getStatus() == CSVEntry.BUILDING_STATUS) { // return; // } // } // } CSVEntry entry = CSVCache.getInstance().getCSV(csvId); if (entry != null) { PersistenceManager pm = PMF.get().getPersistenceManager(); try { ResponseList rl = ResponseManager.getResponse(runId, 0l, null, cursorString); entry = processResponses(pm, rl.getResponses()); if (!(rl.getResponses().isEmpty() || rl.getResumptionToken() == null)) { new CSVGeneration(rl.getResumptionToken(), runId, csvId).scheduleTask(); } else { entry.setStatus(CSVEntry.FINISHED_STATUS); } CSVCache.getInstance().putCSV(csvId, entry); } finally { pm.close(); } } }
public static List<VariableEffectDefinition> getVariableEffectDefinitions( Long gameId, String name) { PersistenceManager pm = PMF.get().getPersistenceManager(); try { ArrayList<VariableEffectDefinition> returnScoreDefinitions = new ArrayList<VariableEffectDefinition>(); Iterator<VariableEffectDefinitionJDO> it = getVariableEffectDefinitions(pm, gameId, name).iterator(); while (it.hasNext()) { returnScoreDefinitions.add(toBean(it.next())); } return returnScoreDefinitions; } finally { pm.close(); } }
public CSVEntry firstIteration() { csvId = UUID.randomUUID().toString(); PersistenceManager pm = PMF.get().getPersistenceManager(); try { ResponseList rl = ResponseManager.getResponse(runId, 0l, null, cursorString); CSVEntry entry = processResponses(pm, rl.getResponses()); if (!(rl.getResponses().isEmpty() || rl.getResumptionToken() == null)) { new CSVGeneration(rl.getResumptionToken(), runId, csvId).scheduleTask(); } else { entry.setStatus(CSVEntry.FINISHED_STATUS); } CSVCache.getInstance().putCSV(csvId, entry); return entry; } finally { pm.close(); } }
public static VariableEffectDefinition createVariableDefinition( VariableEffectDefinition variableDefinition) { PersistenceManager pm = PMF.get().getPersistenceManager(); VariableEffectDefinitionJDO variableEffectDefinitionJDO = new VariableEffectDefinitionJDO(); variableEffectDefinitionJDO.setName(variableDefinition.getName()); variableEffectDefinitionJDO.setGameId(variableDefinition.getGameId()); variableEffectDefinitionJDO.setEffectValue(variableDefinition.getEffectValue()); variableEffectDefinitionJDO.setEffectType(variableDefinition.getEffectType()); if (variableDefinition.getEffectCount() == null) variableDefinition.setEffectCount(1); variableEffectDefinitionJDO.setEffectCount(variableDefinition.getEffectCount()); if (variableDefinition.getId() != null) variableEffectDefinitionJDO.setIdentifier(variableDefinition.getId()); JsonBeanSerialiser jbs = new JsonBeanSerialiser(variableDefinition.getDependsOn()); if (variableDefinition.getDependsOn() != null) variableEffectDefinitionJDO.setDependsOn(new Text(jbs.serialiseToJson().toString())); try { pm.makePersistent(variableEffectDefinitionJDO); return toBean(variableEffectDefinitionJDO); } finally { pm.close(); } }
public static VariableEffectDefinition getEffectDefinition(Long id) { PersistenceManager pm = PMF.get().getPersistenceManager(); Key key = KeyFactory.createKey(VariableEffectDefinitionJDO.class.getSimpleName(), id); return toBean(pm.getObjectById(VariableEffectDefinitionJDO.class, key)); }