コード例 #1
0
  MolgenisUserViewData(MolgenisUser mu, List<MolgenisGroup> molgenisGroups) {
    this(mu.getId(), mu.getUsername());
    firstName = (null == mu.getFirstName() ? "" : mu.getFirstName());
    middleName = (null == mu.getMiddleNames() ? "" : mu.getMiddleNames());
    lastName = (null == mu.getLastName() ? "" : mu.getLastName());

    fullName = firstName + ' ' + middleName + ' ' + lastName;

    this.active = mu.isActive();
    this.superuser = mu.isSuperuser();

    for (MolgenisGroup mg : molgenisGroups) {
      this.groupList.add(mg.getId());
    }
  }
コード例 #2
0
  /**
   * Imports MolgenisGroup from tab/comma delimited File.
   *
   * @param MolgenisGroupFile a tab delimited file with MolgenisGroup data.
   */
  private static void importMolgenisGroup(Database db, File MolgenisGroupFile)
      throws DatabaseException, IOException, Exception {
    logger.debug("trying to import " + MolgenisGroupFile);
    if (!MolgenisGroupFile.exists()) {
      logger.warn("MolgenisGroup.txt file is missing, skipped import");
    } else {
      // read MolgenisGroup from file
      CsvReader reader = new CsvFileReader(MolgenisGroupFile);
      List<MolgenisGroup> molgenisGroupList =
          db.toList(MolgenisGroup.class, reader, Integer.MAX_VALUE); // should have no limit
      logger.debug("loaded " + molgenisGroupList.size() + " MolgenisGroup objects");

      // redirect incoming and outgoing fkeys
      List<Integer> molgenisGroupIds = new ArrayList<Integer>(); // also doesn't scale
      for (int i = 0;
          i < molgenisGroupList.size();
          i++) // sorry, not a real list so need to put back!!
      {
        MolgenisGroup object = molgenisGroupList.get(i);

        // remember index of this id for incoming fkeys
        molgenisGroupIds.add(object.getId());

        // redirect outgoing fkeys

        // add assay back to list
        molgenisGroupList.set(i, object);
      }
      // add to database
      db.add(molgenisGroupList);
      for (int i = 0; i < molgenisGroupList.size(); i++) {
        molgenisGroupIdMap.put(molgenisGroupIds.get(i), molgenisGroupList.get(i).getId());
        molgenisRoleIdMap.put(molgenisGroupIds.get(i), molgenisGroupList.get(i).getId());
      }
    }
  }