コード例 #1
0
ファイル: User.java プロジェクト: BudiPrasetyo20/common
  @Transient
  @JsonIgnore
  public List<String> getAccessableBranch() throws Exception {

    if (NullEmptyChecker.isNullOrEmpty(accessableBranch)) {

      if (getDataAccessRestriction().equals(DataAccessRestriction.AllBranch.getVal())) {

        return null;
      } else if (getDataAccessRestriction().equals(DataAccessRestriction.Subordinate.getVal())) {

        Branch branch = branchRepo.find(getFidBranch());
        System.out.println("branch = " + branch);
        accessableBranch.addAll(branch.getAllSubordinateId());
        accessableBranch.add(getFidBranch());
      } else if (getDataAccessRestriction().equals(DataAccessRestriction.SelfBranch.getVal())) {

        accessableBranch = Arrays.asList(getFidBranch());
      } else {

        String[] accessItem = this.getAccessBranch().split(";");

        for (int x = 0; x < accessItem.length; x++) {
          accessableBranch.add(accessItem[x]);
        }
      }
    }

    return accessableBranch;
  }
コード例 #2
0
 private Collection<GroupData> fetchGroupDataForUser(
     final User user, final boolean restrictToSuscribed) {
   final String ifConnectedColumns =
       "max(ifnull(USER_ID=:userId, false))>0, sum(ifnull(USER_ID=:userId AND LAST_VISIT<PUBLIC_MESSAGES.`DATE`, false))";
   final Query query =
       entityManager.createNativeQuery(
           "select GROUPS.ID, name, count(DISTINCT GROUP_USER.USER_ID), "
               + (user != null ? ifConnectedColumns : " 0,0")
               + " from GROUPS left join  GROUP_USER on GROUP_ID=ID "
               + " left join PUBLIC_MESSAGES on PUBLIC_MESSAGES.GROUP_ID=GROUP_USER.GROUP_ID "
               + (restrictToSuscribed ? " where GROUP_USER.USER_ID=:userId" : "")
               + " group by GROUPS.ID order by CREATION_DATE");
   if (user != null) query.setParameter("userId", user.getId());
   final List<Object[]> list = query.getResultList();
   final Collection<GroupData> result = new ArrayList<GroupData>(list.size());
   for (final Object[] o : list)
     result.add(
         new GroupData(
             ((Number) o[0]).longValue(),
             UserStringImpl.valueOf(String.valueOf(o[1])),
             ((Number) o[2]).longValue(),
             ((Number) o[3]).intValue() != 0,
             ((Number) o[4]).intValue()));
   return result;
 }
コード例 #3
0
 public static List<String> typesList() {
   List<String> theList = new ArrayList<String>();
   for (IdentityDocType type : all()) {
     theList.add(type.identityDocTypeName);
   }
   return theList;
 }
コード例 #4
0
ファイル: JPAPlugin.java プロジェクト: visan/play1
 public List<Model.Property> listProperties() {
   List<Model.Property> properties = new ArrayList<Model.Property>();
   Set<Field> fields = new LinkedHashSet<Field>();
   Class<?> tclazz = clazz;
   while (!tclazz.equals(Object.class)) {
     Collections.addAll(fields, tclazz.getDeclaredFields());
     tclazz = tclazz.getSuperclass();
   }
   for (Field f : fields) {
     int mod = f.getModifiers();
     if (Modifier.isTransient(mod) || Modifier.isStatic(mod)) {
       continue;
     }
     if (f.isAnnotationPresent(Transient.class)) {
       continue;
     }
     if (f.isAnnotationPresent(NoBinding.class)) {
       NoBinding a = f.getAnnotation(NoBinding.class);
       List<String> values = Arrays.asList(a.value());
       if (values.contains("*")) {
         continue;
       }
     }
     Model.Property mp = buildProperty(f);
     if (mp != null) {
       properties.add(mp);
     }
   }
   return properties;
 }
コード例 #5
0
ファイル: MovementsDAOImpl.java プロジェクト: niekert/ROAD
  /**
   * Generate license plates from a file.
   *
   * @param filename
   */
  private void generateLicensePlates(String filename) {
    File licenseplatefile = getResourceFile(filename);
    BufferedReader in = null;
    try {
      in = new BufferedReader(new InputStreamReader(new FileInputStream(licenseplatefile)));
    } catch (FileNotFoundException ex) {
      Logger.getLogger(MovementsDAOImpl.class.getName()).log(Level.SEVERE, null, ex);
    }

    List<String> licensePlates = new ArrayList();
    String line;

    try {
      while ((line = in.readLine()) != null) {
        licensePlates.add(line);
      }
    } catch (IOException ex) {
      Logger.getLogger(MovementsDAOImpl.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
      try {
        in.close();
      } catch (IOException ex) {
        Logger.getLogger(MovementsDAOImpl.class.getName()).log(Level.SEVERE, null, ex);
      }
    }
    itLicensePlates = licensePlates.iterator();
  }
コード例 #6
0
ファイル: JPAPlugin.java プロジェクト: visan/play1
 Field[] keyFields() {
   Class c = clazz;
   try {
     List<Field> fields = new ArrayList<Field>();
     while (!c.equals(Object.class)) {
       for (Field field : c.getDeclaredFields()) {
         // TODO: add cashe field->isAnnotationPresent
         if (InternalCache.isEnableAnnotationPresent()) {
           if (InternalCache.isAnnotationPresent(Id.class, field)
               || InternalCache.isAnnotationPresent(EmbeddedId.class, field)) {
             field.setAccessible(true);
             fields.add(field);
           }
         } else {
           if (field.isAnnotationPresent(Id.class)
               || field.isAnnotationPresent(EmbeddedId.class)) {
             field.setAccessible(true);
             fields.add(field);
           }
         }
       }
       c = c.getSuperclass();
     }
     final Field[] f = fields.toArray(new Field[fields.size()]);
     if (f.length == 0) {
       throw new UnexpectedException("Cannot get the object @Id for an object of type " + clazz);
     }
     return f;
   } catch (Exception e) {
     throw new UnexpectedException(
         "Error while determining the object @Id for an object of type " + clazz);
   }
 }
コード例 #7
0
ファイル: Job.java プロジェクト: eguller/mujobo
 public String getFirstLatLng() {
   if (mapLocationList.size() == 0) {
     return "0,0";
   } else {
     return mapLocationList.get(0).getLatitude() + ", " + mapLocationList.get(0).getLatitude();
   }
 }
コード例 #8
0
ファイル: Doctor.java プロジェクト: ArtemVoronov/mis_nsu
 public static List<String> fioList() {
   List<String> theList = new ArrayList<String>();
   for (Doctor doctor : allDoctors()) {
     theList.add(doctor.getFullName());
   }
   return theList;
 }
コード例 #9
0
ファイル: Comment.java プロジェクト: arcuri82/pg6100
 public void addComment(Comment comment) {
   if (!comment.isCommentSet()) {
     List<Comment> commentList = getComments();
     commentList.add(comment);
     comment.commentSet = true;
   }
 }
コード例 #10
0
ファイル: ResearchStaff.java プロジェクト: gopuv/caaers
  /**
   * Will return SiteResearchStaff having at least one active role provided in roleCodes parameter.
   *
   * @param roleCodes - roles to check
   * @return A list of SiteResearchStaff
   */
  public List<SiteResearchStaff> findSiteResearchStaffByRoles(final String... roleCodes) {
    List<SiteResearchStaff> srsList = new ArrayList<SiteResearchStaff>();
    for (SiteResearchStaff srs : getSiteResearchStaffs()) {
      if (srs.hasActiveRolesOfType(roleCodes)) srsList.add(srs);
    }

    return srsList;
  }
コード例 #11
0
ファイル: ResearchStaff.java プロジェクト: gopuv/caaers
 /**
  * Will return all the SiteResearchStaff which are currently active.
  *
  * @return the in active site research staff
  */
 @Transient
 public List<SiteResearchStaff> getInActiveSiteResearchStaff() {
   List<SiteResearchStaff> srsList = new ArrayList<SiteResearchStaff>();
   for (SiteResearchStaff srs : getSiteResearchStaffs()) {
     if (!srs.isActive()) srsList.add(srs);
   }
   return srsList;
 }
コード例 #12
0
 @Override
 public List<ICompetition> getCompetitions() {
   List<ICompetition> cl = new LinkedList<>();
   for (Competition c : competitions) {
     cl.add(c);
   }
   return cl;
 }
コード例 #13
0
ファイル: Nalog.java プロジェクト: gasperr/travel-expense
 public List<ServiceEntity> getServices() {
   if (services == null) {
     services = new HashSet<>();
   }
   List<ServiceEntity> rtrn = new ArrayList<>();
   rtrn.addAll(services);
   return rtrn;
 }
コード例 #14
0
 @Transient
 private List<ArticlePageEntityDTO> getPagesAsDTOs() {
   List<ArticlePageEntityDTO> pageDTOs = new ArrayList<>();
   for (ArticlePage page : pages) {
     pageDTOs.add(page.toDTO());
   }
   return pageDTOs;
 }
コード例 #15
0
ファイル: Nalog.java プロジェクト: gasperr/travel-expense
 public List<Message> getRelatedMessage() {
   if (relatedMessage == null) {
     relatedMessage = new HashSet<>();
   }
   List<Message> rtrn = new ArrayList<>();
   rtrn.addAll(relatedMessage);
   return rtrn;
 }
コード例 #16
0
ファイル: Audit.java プロジェクト: bgarrels/xpert-framework
  /**
   * Persists a Audit
   *
   * @param object
   * @param persisted
   * @param auditingType
   */
  public void audit(Object object, Object persisted, AuditingType auditingType) {

    try {

      if (isEntity(object)) {

        Field[] fields = object.getClass().getDeclaredFields();
        Method[] methods = object.getClass().getDeclaredMethods();
        Method.setAccessible(methods, true);
        Field.setAccessible(fields, true);

        AbstractAuditing auditing = Configuration.getAbstractAuditing();
        auditing.setIdentifier(Long.valueOf(getId(object).toString()));
        auditing.setEntity(getEntityName(object.getClass()));
        auditing.setAuditingType(auditingType);
        auditing.setEventDate(new Date());
        if (FacesContext.getCurrentInstance() != null) {
          auditing.setIp(FacesUtils.getIP());
        }
        auditing.setAuditClass(object.getClass());
        AbstractAuditingListener listener = Configuration.getAuditingListener();
        if (listener != null) {
          listener.onSave(auditing);
        }

        List<AbstractMetadata> metadatas = null;
        boolean auditPersited = false;
        if (auditingType.equals(AuditingType.INSERT) || auditingType.equals(AuditingType.DELETE)) {
          entityManager.persist(auditing);
          metadatas = getMetadata(object, null, auditing);
          auditPersited = true;
        } else if (auditingType.equals(AuditingType.UPDATE)) {
          metadatas = getMetadata(object, persisted, auditing);
          if (metadatas != null && !metadatas.isEmpty()) {
            entityManager.persist(auditing);
            auditPersited = true;
          }
        }

        auditing.setMetadatas(metadatas);
        // add to context
        if (auditPersited == true) {
          AuditContext context = AuditContext.getCurrentInstance();
          if (context != null) {
            context.setAuditing(object, auditing);
          }
        }

        if (metadatas != null && !metadatas.isEmpty()) {
          for (AbstractMetadata metadata : metadatas) {
            entityManager.persist(metadata);
          }
        }
      }
    } catch (Throwable t) {
      logger.log(Level.SEVERE, t.getMessage(), t);
    }
  }
コード例 #17
0
ファイル: MovementsDAOImpl.java プロジェクト: niekert/ROAD
  /**
   * Get a vehicle by cartracker id from the cached list, if the vehicle does not exist it will be
   * created.
   *
   * @param cartrackerID
   * @return The found or newly created vehicle.
   */
  @Override
  public Vehicle getOrCreateVehicleById(String cartrackerID) {
    Vehicle returnVehicle = null;

    Iterator<Vehicle> it = vehicles.iterator();
    while (it.hasNext()) {
      Vehicle vehicle = it.next();
      if (cartrackerID.equals(vehicle.getCarTrackerID())) {
        returnVehicle = vehicle;
        break;
      }
    }

    /* Vehicle does not exist, lets create a new one */
    if (returnVehicle == null) {
      try {
        /* Also create a vehicle ownership */
        GregorianCalendar registerdate = new GregorianCalendar();
        registerdate.add(Calendar.YEAR, -3);
        VehicleOwnership vehicleOwnership = new VehicleOwnership();
        vehicleOwnership.setContributeGPSData(true);
        vehicleOwnership.setRegistrationdate((GregorianCalendar) registerdate.clone());
        vehicleOwnership.setRegistrationExperationDate(null);
        try {
          // create new user with incrementing name
          userDAO = new UserDAOImpl(emf);
          loginDAO = new LoginDAOImpl(em);
          UserDto user =
              userDAO.register(
                  "user" + USER_ID++ + "name", "aidas123", "*****@*****.**");
          MovementUser mUser = loginDAO.register(user.getUsername(), user.getEmail());
          vehicleOwnership.setUser(mUser);
        } catch (UserSystemException ex) {
          Logger.getLogger(MovementsDAOImpl.class.getName()).log(Level.SEVERE, null, ex);
        }

        // create car
        returnVehicle = new Vehicle(cartrackerID);
        returnVehicle.setLicensePlate(itLicensePlates.next());
        List<VehicleOwnership> owners = new ArrayList();
        owners.add(vehicleOwnership);
        returnVehicle.setVehicleOwners(owners);
        em.persist(returnVehicle);

        vehicleOwnership.setVehicle(returnVehicle);
        em.persist(vehicleOwnership);
        Logger.getLogger(MovementsDAOImpl.class.getName())
            .log(Level.WARNING, "Created new vehicle with ID" + cartrackerID);

        this.vehicles.add(returnVehicle);
      } catch (Exception ex) {
        Logger.getLogger(MovementsDAOImpl.class.getName()).log(Level.SEVERE, null, ex);
      }
    }

    return returnVehicle;
  }
コード例 #18
0
 public static List<MetaModule> createAll() {
   List<MetaModule> result = new ArrayList<MetaModule>();
   for (Object oapp : MetaApplications.getMetaApplications()) {
     MetaApplication app = (MetaApplication) oapp;
     createDefaultMetaModules(app);
     createAdditionalMetaModules(app);
     result.addAll(app.getMetaModules());
   }
   return result;
 }
コード例 #19
0
  @Override
  public void setCompetitions(List<ICompetition> competitions) {
    List<Competition> result = new LinkedList<>();

    for (ICompetition d : competitions) {
      result.add((Competition) d);
    }

    this.competitions = result;
  }
コード例 #20
0
ファイル: PullRequest.java プロジェクト: hurims/yobi
 /**
  * groupKey를 통해 같은 코멘트그룹을 반환한다.
  *
  * @param groupKey
  * @param codeComments
  * @return
  */
 private List<CommitComment> commitCommentsGroupByKey(
     String groupKey, List<CommitComment> codeComments) {
   List<CommitComment> commitCommentGroups = new ArrayList<>();
   for (CommitComment commitComment : codeComments) {
     if (commitComment.groupKey().equals(groupKey)) {
       commitCommentGroups.add(commitComment);
     }
   }
   return commitCommentGroups;
 }
コード例 #21
0
  @Override
  public void setTeamList(List<ITeam> teamList) {
    List<Team> result = new LinkedList<>();

    for (ITeam d : teamList) {
      result.add((Team) d);
    }

    this.teamList = result;
  }
コード例 #22
0
  @XmlTransient
  @Override
  public List<ITeam> getTeamList() {
    List<ITeam> result = new LinkedList<>();

    for (Team d : teamList) {
      result.add(d);
    }

    return result;
  }
コード例 #23
0
ファイル: User.java プロジェクト: carliros/trainer
  public DataModel<Event> getMyEvents() {
    DataModel<Event> events = null; //
    Set<Event> myEvents = getSubscribedEvents();
    // EventRegistry eventRegistry = EventRegistry.getCurrentInstance();

    List<Event> myEventList = new ArrayList<Event>();
    myEventList.addAll(myEvents);

    events = new ListDataModel<Event>(myEventList);

    return events;
  }
コード例 #24
0
ファイル: Room.java プロジェクト: tanacasino/webchat
 public static List<Room> findJoinedRoomsByUser(User user) {
   // ユーザが所属するルーム一覧の取得.
   // FIXME JOINとか使わないとどう考えてもだめだよー。HQLとJPAがわからないので一旦放置.
   List<Room> rooms = findAll();
   List<Room> ret = new ArrayList<Room>();
   for (Room room : rooms) {
     if (room.members.contains(user)) {
       ret.add(room);
     }
   }
   return ret;
 }
コード例 #25
0
ファイル: PullRequest.java プロジェクト: hurims/yobi
  /**
   * 답글목록을 부모글의 필드로 재할당한다.
   *
   * <p>commentGroup은 등록일순으로 오름차순 정렬되어 있는 상태이며 목록의 첫번째 코멘트를 부모글로 판단한다.
   *
   * @param commentGroup
   * @return
   */
  private List<CommitComment> reAssignReplyComments(Map<String, List<CommitComment>> commentGroup) {
    List<CommitComment> parentCommitComments = new ArrayList<>();

    for (List<CommitComment> commitComments : commentGroup.values()) {
      CommitComment parentComment = commitComments.get(0);
      if (hasReply(commitComments)) {
        parentComment.replies = replies(commitComments);
      }
      parentCommitComments.add(parentComment);
    }
    return parentCommitComments;
  }
コード例 #26
0
ファイル: OrderPlaceDDAO.java プロジェクト: borislu/KaiJung
  public Stock getStockByItem(int itemid) { // 用 商品編號 查出 該商品所在的某一貨架
    Query query =
        XPersistence.getManager()
            .createQuery(
                "FROM Stock o WHERE o.item.oid = :itemid order by o.volume desc"); // JPQL query
    query.setParameter("itemid", itemid);

    List<Stock> beans = query.getResultList();
    logger.debug("OrderPlaceDDAO.getStockByItem beans: " + beans);

    return beans.get(0);
  }
コード例 #27
0
 public void forgotPassword(final String email) throws UserNotFoundException, MailException {
   final Query query =
       entityManager.createQuery("select u from UserImpl u where u.email=:cryptedMail");
   query.setParameter("cryptedMail", CipherHelper.cipher(email));
   final List<UserImpl> list = query.getResultList();
   if (list.isEmpty()) throw new UserNotFoundException();
   for (final UserImpl user : list) {
     final String password = Helper.randomstring();
     user.setPassword(password);
     MailSender.forgotPasswordMail(user.getName(), password, email);
     entityManager.merge(user);
   }
 }
コード例 #28
0
ファイル: User.java プロジェクト: astolarz/OpenBook
 public List<Group> getGroups() {
   List<Group> allGroups = Group.findAll();
   List<Group> answer = new ArrayList<Group>();
   for (Group g : allGroups) {
     for (User u : g.members) {
       if (u.equals(this)) {
         answer.add(g);
         break;
       }
     }
   }
   return answer;
 }
コード例 #29
0
ファイル: Boulder.java プロジェクト: RyanBrushett/Ticklist
 public Boulder untick(String name) {
   int i = 0;
   while (i < haveSent.size()) {
     if (haveSent.get(i).username.equals(name)) {
       haveSent.remove(i);
       this.update();
       return this;
     } else {
       ++i;
     }
   }
   return null;
 }
コード例 #30
0
ファイル: PullRequest.java プロジェクト: hurims/yobi
  /**
   * pull request의 모든 코멘트 정보를 가져오고 시간순으로 정렬 후 반환한다. (코멘트 + 코드코멘트 + 이벤트 )
   *
   * @return
   */
  @Transient
  public List<TimelineItem> getTimelineComments() {
    List<CommitComment> commitComment = computeCommitCommentReplies(getCommitComments());

    List<TimelineItem> timelineComments = new ArrayList<>();
    timelineComments.addAll(comments);
    timelineComments.addAll(commitComment);
    timelineComments.addAll(pullRequestEvents);

    Collections.sort(timelineComments, TimelineItem.ASC);

    return timelineComments;
  }