コード例 #1
0
  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;
  }
コード例 #2
0
 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();
   }
 }
コード例 #4
0
 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;
 }
コード例 #5
0
 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;
 }
コード例 #6
0
 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;
 }
コード例 #7
0
 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;
 }
コード例 #8
0
ファイル: UserManager.java プロジェクト: bsceran/lab1
 @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;
 }
コード例 #9
0
 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;
 }
コード例 #10
0
ファイル: CompteDaoImpl.java プロジェクト: kodokuwashi/MyBank
 @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);
 }
コード例 #11
0
 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());
     }
   }
 }
コード例 #12
0
  @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;
  }
コード例 #13
0
  @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;
  }
コード例 #14
0
 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;
 }
コード例 #15
0
 public User getByName(String username) {
   return mongoOperations.findOne(
       Query.query(Criteria.where("userName").is(username)), User.class);
 }
コード例 #16
0
 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);
 }
コード例 #19
0
ファイル: SeasonDaoImpl.java プロジェクト: ppk19052014/ppk
 public Season readByTournament(String tournamentId) {
   Query searchSeasonQuery = new Query(Criteria.where("tournamentId").is(tournamentId));
   return mongoOperation.findOne(searchSeasonQuery, Season.class);
 }
コード例 #20
0
ファイル: SeasonDaoImpl.java プロジェクト: ppk19052014/ppk
 @Override
 public Season read(String id) {
   Query searchSeasonQuery = new Query(Criteria.where("id").is(id));
   return mongoOperation.findOne(searchSeasonQuery, Season.class);
 }
コード例 #21
0
 public Article findArticleById(String id) {
   Query query = query(where("_id").is(new ObjectId(id)));
   return operations.findOne(query, Article.class);
 }
コード例 #22
0
 @Override
 public User getById(BigInteger id) {
   return mongoOperations.findOne(Query.query(Criteria.where("id").is(id)), User.class);
 }
コード例 #23
0
ファイル: CompteDaoImpl.java プロジェクト: kodokuwashi/MyBank
 @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);
 }
コード例 #24
0
 @Override
 public E findByCpf(String cpf) {
   final Query query = query(where("cpf").is(cpf));
   return operations.findOne(query, type);
 }