public Project getProject(String projectid) throws NullMongoTemplateException { MongoOperations mongoOperations = getMongoOperationInstance(); if (mongoOperations == null) { throw new NullMongoTemplateException(); } Project project = mongoOperations.findOne(query(where("_id").is(projectid)), Project.class); if (project.getProjecttype().equals("SCRUM")) { ProjectScrum ps = mongoOperations.findOne(query(where("_id").is(projectid)), ProjectScrum.class, "project"); project = ps; } return project; }
public Map<String, Integer> getQueuesOverLimit(String projectid, String projecttype) throws NullMongoTemplateException { MongoOperations mongoOperations = getMongoOperationInstance(); if (mongoOperations == null) { throw new NullMongoTemplateException(); } ProjectWF project = mongoOperations.findOne(query(where("_id").is(projectid)), ProjectWF.class, "project"); List<Task> tasks = project.getTasks(); int countReady = 0; int countInProgress = 0; int countComplete = 0; for (Task task : tasks) { if (task.getStatus().equals("1")) { countReady++; } else if (task.getStatus().equals("2")) { countInProgress++; } else { countComplete++; } } Map<String, Integer> table = new Hashtable<>(); table.put("Ready", countReady); table.put("Inprogress", countInProgress); table.put("Completed", countComplete); return table; }
@Override public void rollback(Change change) { OperationType operationType = change.getOperationType(); try { switch (operationType) { case CREATE: { Object targetObject = change.getNewObject(); Query removeQuery = createFindQuery(targetObject); Object removedObject = mongoOperations.findOne(removeQuery, targetObject.getClass()); if (removedObject != null) { mongoOperations.remove(removedObject); } break; } case UPDATE: case DELETE: { mongoOperations.save(change.getOldObject()); break; } } } catch (Exception exc) { exc.printStackTrace(); } }
public int getPercentageComplete(String projectid, String projecttype) throws NullMongoTemplateException { MongoOperations mongoOperations = getMongoOperationInstance(); if (mongoOperations == null) { throw new NullMongoTemplateException(); } ProjectKanban project = mongoOperations.findOne(query(where("_id").is(projectid)), ProjectKanban.class, "project"); List<Task> tasks = project.getTasks(); int countReady = 0; int countInProgress = 0; int countComplete = 0; for (Task task : tasks) { if (task.getStatus().equals("Ready")) { countReady++; } else if (task.getStatus().equals("Inprogress")) { countInProgress++; } else { countComplete++; } } int totalCount = countComplete + countReady + countInProgress; System.out.println(countComplete + countReady + countInProgress); int percentageComplete = (1 / 3) * 100; return percentageComplete; }
public Sprint findSprintinProject( String username, String projectName, String projectType, String sprintName) throws NullMongoTemplateException { Sprint sprint = null; MongoOperations mongoOperations = getMongoOperationInstance(); if (mongoOperations == null) { throw new NullMongoTemplateException(); } ProjectScrum project = mongoOperations.findOne( query( where("projectname") .is(projectName) .and("ownername") .is(username) .and("projecttype") .is(projectType)), ProjectScrum.class); if (project != null) { List<Sprint> sprints = project.getSprints(); if (sprints.size() == 0) { return null; } for (Sprint sprint1 : sprints) { if (sprint1.getSprintName().equals(sprintName)) { sprint = sprint1; break; } } } return sprint; }
public String getProjecttype(String projectid) throws NullMongoTemplateException { MongoOperations mongoOperations = getMongoOperationInstance(); if (mongoOperations == null) { throw new NullMongoTemplateException(); } Project project = mongoOperations.findOne(query(where("_id").is(projectid)), Project.class); String projectType = project.getProjecttype(); return projectType; }
public List<Task> getTasks(String projectid) throws NullMongoTemplateException { MongoOperations mongoOperations = getMongoOperationInstance(); if (mongoOperations == null) { throw new NullMongoTemplateException(); } Project project = mongoOperations.findOne(query(where("_id").is(projectid)), Project.class); List<Task> tasks = project.getTasks(); return tasks; }
@Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { Query query = new Query(Criteria.where("username").is(username)); User user = mongoOperations.findOne(query, User.class); if (user == null) { throw new UsernameNotFoundException(username); } return user; }
public List<Sprint> getSprints(String projectid) throws NullMongoTemplateException { MongoOperations mongoOperations = getMongoOperationInstance(); if (mongoOperations == null) { throw new NullMongoTemplateException(); } ProjectScrum project = mongoOperations.findOne(query(where("_id").is(projectid)), ProjectScrum.class, "project"); List<Sprint> sprints = project.getSprints(); return sprints; }
@Override public Compte recupererCompte(String libelle, String proprietaire) { final Query query = new Query(); query.addCriteria( Criteria.where(Constantes.ChampCollectionCompte.LIBELLE) .is(libelle) .and(Constantes.ChampCollectionCompte.PROPRIETAIRE) .is(proprietaire)); return mongoOperations.findOne(query, Compte.class); }
private void keepTenantFields(final TenantResource entityResource) { final Criteria criteria = Criteria.where("_id").is(entityResource.getId()); final TenantResource resource = mongoOps.findOne(new Query(criteria), entityResource.getClass()); if (resource != null) { entityResource.setTenantsAuth(resource.getTenantsAuth()); entityResource.setTenantId(resource.getTenantId()); // And finally, if tenantResource is Component, keep its tenantsMapVisible members if (entityResource instanceof Component) { ((Component) entityResource) .getTenantsMapVisible() .addAll(((Component) resource).getTenantsMapVisible()); } } }
@Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { ApplicationContext ctx = new AnnotationConfigApplicationContext(SpringMongoConfig.class); MongoOperations mongoOperation = (MongoOperations) ctx.getBean("mongoTemplate"); Query query = new Query(); User user = null; try { query.addCriteria(Criteria.where("username").is(username)); user = mongoOperation.findOne(query, User.class); } catch (Exception e) { System.out.println("IS THISIISSTT"); e.printStackTrace(); } if (user == null) { throw new UsernameNotFoundException("CAROLINA"); } return user; }
@Override public List<String> getFilesWithWord(String word, String uid) { List<String> result = new ArrayList<>(); Query query = new Query(); if (uid != null) { query.addCriteria(Criteria.where("name").is(word).and("foundIn.uid").is(uid)); } else { query.addCriteria(Criteria.where("name").is(word)); } Word queryResult = mongo.findOne(query, Word.class); if (queryResult != null) { result.addAll( queryResult.getFoundIn().stream().map(File::getFid).collect(Collectors.toList())); } return result; }
public int getHoursRemaining(String projectid, String projecttype) throws NullMongoTemplateException { MongoOperations mongoOperations = getMongoOperationInstance(); if (mongoOperations == null) { throw new NullMongoTemplateException(); } ProjectScrum project = mongoOperations.findOne(query(where("_id").is(projectid)), ProjectScrum.class, "project"); int totalHours = 0; int hoursCompleted = 0; List<Sprint> sprints = project.getSprints(); for (Sprint sprint : sprints) { List<TaskScrum> tasks = sprint.getTasks(); for (TaskScrum task : tasks) { totalHours = totalHours + task.getHoursAllotted(); hoursCompleted = hoursCompleted + task.getHoursCompleted(); } } int hoursRemaining = totalHours - hoursCompleted; return hoursRemaining; }
public User getByName(String username) { return mongoOperations.findOne( Query.query(Criteria.where("userName").is(username)), User.class); }
public SecurityUser getUserByUsername(String username) { return mongoOperations.findOne( Query.query(Criteria.where("username").is(username)), SecurityUser.class); }
public CreditTransaction getTransactionByReceipt(String OR) throws UnknownHostException { return transactionMongoOps.findOne( generateQuery("officialReceipt", OR), CreditTransaction.class); }
public CreditTransaction getCreditTransactionById(String id) throws UnknownHostException { Query query = new Query(); query.addCriteria(where("id").is(id)); return transactionMongoOps.findOne(query, CreditTransaction.class); }
public Season readByTournament(String tournamentId) { Query searchSeasonQuery = new Query(Criteria.where("tournamentId").is(tournamentId)); return mongoOperation.findOne(searchSeasonQuery, Season.class); }
@Override public Season read(String id) { Query searchSeasonQuery = new Query(Criteria.where("id").is(id)); return mongoOperation.findOne(searchSeasonQuery, Season.class); }
public Article findArticleById(String id) { Query query = query(where("_id").is(new ObjectId(id))); return operations.findOne(query, Article.class); }
@Override public User getById(BigInteger id) { return mongoOperations.findOne(Query.query(Criteria.where("id").is(id)), User.class); }
@Override public Compte recupererCompteById(String idCompte) { final Query query = new Query(); query.addCriteria(Criteria.where(Constantes.ChampCollectionCompte.IDCOMPTE).is(idCompte)); return mongoOperations.findOne(query, Compte.class); }
@Override public E findByCpf(String cpf) { final Query query = query(where("cpf").is(cpf)); return operations.findOne(query, type); }