Ejemplo n.º 1
0
 public String getFirstLatLng() {
   if (mapLocationList.size() == 0) {
     return "0,0";
   } else {
     return mapLocationList.get(0).getLatitude() + ", " + mapLocationList.get(0).getLatitude();
   }
 }
Ejemplo n.º 2
0
  /**
   * diff commit message로 pull request의 title과 body를 채운다.<br>
   * <br>
   * case 1 : commit이 한개이고 message가 한줄일 경우 title에 추가한다.<br>
   * case 2 : commit이 한개이고 message가 여러줄일 경우 첫번째줄 mesage는 title 나머지 message는 body에 추가<br>
   * case 3 : commit이 여러개일 경우 각 commit의 첫번째줄 message들을 모아서 body에 추가 <br>
   *
   * @param commits
   * @return
   */
  private Map<String, String> suggestTitleAndBodyFromDiffCommit(List<GitCommit> commits) {
    Map<String, String> messageMap = new HashMap<>();

    String message;

    if (commits.isEmpty()) {
      return messageMap;

    } else if (commits.size() == 1) {
      message = commits.get(0).getMessage();
      String[] messages = message.split(Constants.NEW_LINE_DELIMETER);

      if (messages.length > 1) {
        String[] msgs = Arrays.copyOfRange(messages, 1, messages.length);
        messageMap.put("title", messages[0]);
        messageMap.put("body", StringUtils.join(msgs, Constants.NEW_LINE_DELIMETER));

      } else {
        messageMap.put("title", messages[0]);
        messageMap.put("body", StringUtils.EMPTY);
      }

    } else {
      String[] firstMessages = new String[commits.size()];
      for (int i = 0; i < commits.size(); i++) {
        String[] messages = commits.get(i).getMessage().split(Constants.NEW_LINE_DELIMETER);
        firstMessages[i] = messages[0];
      }
      messageMap.put("body", StringUtils.join(firstMessages, Constants.NEW_LINE_DELIMETER));
    }

    return messageMap;
  }
Ejemplo n.º 3
0
  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);
  }
Ejemplo n.º 4
0
  /**
   * 답글목록을 부모글의 필드로 재할당한다.
   *
   * <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;
  }
Ejemplo n.º 5
0
 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;
 }
Ejemplo n.º 6
0
  public void importColumns() throws Exception {
    LOGGER.info("List of objects for source: " + stageSourceCode);
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("OpenBIStage");
    EntityManager em = emf.createEntityManager();
    Query query;

    // get source
    query = em.createQuery("SELECT x FROM StageSource x WHERE x.etlStageSourceCode = ?1");
    query.setParameter(1, stageSourceCode);
    List<StageSource> sources = query.getResultList();

    // get source objects and dbs
    List<StageObject> objects = sources.get(0).getStageObject();
    List<StageSourceDb> sourcedbs = sources.get(0).getStageSourceDb();

    // load properties from property file
    String dbpropertyfile =
        "datasources/" + sourcedbs.get(0).getEtlStageSourceDbJdbcname() + ".properties";
    Properties dbproperties = new Properties();
    dbproperties.load(new FileInputStream(dbpropertyfile));

    // Configure db connection
    org.opendatakraken.core.db.DBConnection sourceConnectionBean =
        new org.opendatakraken.core.db.DBConnection();
    sourceConnectionBean.setPropertyFile(dbproperties.getProperty("srcconnaddpropertyfile"));
    sourceConnectionBean.setDatabaseDriver(dbproperties.getProperty("srcdbdriverclass"));
    sourceConnectionBean.setConnectionURL(dbproperties.getProperty("srcdbconnectionurl"));
    sourceConnectionBean.setUserName(dbproperties.getProperty("srcdbusername"));
    sourceConnectionBean.setPassWord(dbproperties.getProperty("srcdbpassword"));
    sourceConnectionBean.openConnection();

    DictionaryExtractor dataDict = new DictionaryExtractor();
    dataDict.setSourceConnection(sourceConnectionBean);

    // For each object
    String sourceIdentifier;
    for (StageObject object : objects) {

      // Dermine source identifier
      sourceIdentifier = object.getEtlStageObjectName();
      if (!(sourcedbs.get(0).getEtlStageSourceOwner().equals(""))
          && sourcedbs.get(0).getEtlStageSourceOwner() != null) {
        sourceIdentifier = sourcedbs.get(0).getEtlStageSourceOwner() + "." + sourceIdentifier;
      }

      dataDict.setSourceTable(sourceIdentifier);
      dataDict.retrieveColumns();

      String[] colNames = dataDict.getColumnNames();
      String[] colDefs = dataDict.getColumnDefinition();
      String[] colOriginalDefs = dataDict.getColumnDefinition();
      int[] colPkPos = dataDict.getColumnPkPositions();

      em.getTransaction().begin();

      for (int i = 0; i < colNames.length; i++) {
        query =
            em.createQuery(
                "SELECT x FROM StageColumn x WHERE x.etlStageObjectId = ?1 AND x.etlStageColumnName = ?2");
        query.setParameter(1, object.getEtlStageObjectId());
        query.setParameter(2, colNames[i]);
        List<StageColumn> columns = query.getResultList();

        StageColumn column;
        if (columns.size() == 0) {
          column = new StageColumn();
          column.setEtlStageObjectId(BigDecimal.valueOf(object.getEtlStageObjectId()));
          column.setEtlStageColumnPos(BigDecimal.valueOf(i + 1));
          column.setEtlStageColumnName(colNames[i]);
          column.setEtlStageColumnDef(colDefs[i]);
          column.setEtlStageColumnDefSrc(colOriginalDefs[i]);
          column.setEtlStageColumnEdwhFlag(BigDecimal.valueOf(1));
          if (colPkPos[i] > 0) {
            column.setEtlStageColumnNkPos(BigDecimal.valueOf(colPkPos[i]));
            object.setEtlStageSourceNkFlag(BigDecimal.valueOf(1));
          }
          em.persist(column);
        } else {
          column = columns.get(0);
          column.setEtlStageColumnPos(BigDecimal.valueOf(i + 1));
          column.setEtlStageColumnDef(colDefs[i]);
          column.setEtlStageColumnDefSrc(colOriginalDefs[i]);
          if (colPkPos[i] > 0) {
            column.setEtlStageColumnNkPos(BigDecimal.valueOf(colPkPos[i]));
            object.setEtlStageSourceNkFlag(BigDecimal.valueOf(1));
          }
        }
      }
      em.getTransaction().commit();
    }
  }