Exemple #1
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;
  }
Exemple #2
0
 public String getFirstLatLng() {
   if (mapLocationList.size() == 0) {
     return "0,0";
   } else {
     return mapLocationList.get(0).getLatitude() + ", " + mapLocationList.get(0).getLatitude();
   }
 }
Exemple #3
0
 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);
   }
 }
 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;
 }
  public static void main(String[] args) throws Exception {
    HashMap map = new HashMap();
    // map.put("hibernate.show_sql", "true");
    EntityManagerFactory factory = Persistence.createEntityManagerFactory("titan", map);
    EntityManager entityManager = factory.createEntityManager();
    entityManager.getTransaction().begin();
    try {
      System.out.println("Initialize DB");
      InitializeDB.initialize(entityManager);
      System.out.println();
      System.out.println();

      System.out.println("Find Bill Burke by named parameter");
      Customer cust = findCustomerByNamedParameter(entityManager, "Bill", "Burke");
      System.out.println("Bill Burke's cust id: " + cust.getId());
      System.out.println();
      System.out.println();

      System.out.println("Find Gavin King by indexed parameter");
      cust = findCustomerByIndexedParameter(entityManager, "Gavin", "King");
      System.out.println("Gavin King's cust id: " + cust.getId());
      System.out.println();
      System.out.println();

      System.out.println("Output all customers via paging");
      List results;
      int first = 0;
      int max = 2;
      do {
        results = getCustomers(entityManager, max, first);
        Iterator it = results.iterator();
        while (it.hasNext()) {
          Customer c = (Customer) it.next();
          System.out.println(c.getFirstName() + " " + c.getLastName());
        }
        entityManager.clear();
        first = first + results.size();
      } while (results.size() > 0);
    } finally {
      entityManager.getTransaction().commit();
      entityManager.close();
      factory.close();
    }
  }
 public static void initialiseSubscriptions(
     EntityManagerFactory entityManagerFactory, Long immediateFrequency) {
   EntityManager badSubsEm = entityManagerFactory.createEntityManager();
   TypedQuery<Subscription> badSubsQuery =
       badSubsEm.createNamedQuery("subscription.unInitialised", Subscription.class);
   List<Subscription> uninitialisedSubscriptions = badSubsQuery.getResultList();
   badSubsEm.close();
   if (uninitialisedSubscriptions.size() > 0) {
     logger.debug("Initialising {} subscriptions", uninitialisedSubscriptions.size());
     for (Subscription s : uninitialisedSubscriptions) {
       logger.debug(
           "Scheduling new run for {} subscription {}", s.getSubscriber().emailAddress, s.getId());
       EntityManager schedEm = entityManagerFactory.createEntityManager();
       schedEm.getTransaction().begin();
       s.calculateNextScheduledRun(immediateFrequency);
       schedEm.merge(s);
       schedEm.getTransaction().commit();
       schedEm.close();
     }
   }
 }
Exemple #7
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;
 }
Exemple #8
0
  private List<Class> findEntityClassesForThisConfig(String configName, String propPrefix) {
    // look and see if we have any Entity-objects for this db config
    List<Class> classes = Play.classloader.getAnnotatedClasses(Entity.class);

    // filter list on Entities meant for us..
    List<Class> filteredClasses = new ArrayList<Class>(classes.size());
    for (Class clazz : classes) {
      if (configName.equals(Entity2JPAConfigResolver.getJPAConfigNameForEntityClass(clazz))) {
        filteredClasses.add(clazz);
      }
    }

    if (!Play.configuration.getProperty(propPrefix + "jpa.entities", "").equals("")) {
      return filteredClasses;
    }

    if (filteredClasses.isEmpty()) {
      return null;
    }

    return filteredClasses;
  }
  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();
    }
  }
Exemple #10
0
 /**
  * 답글 유무를 체크한다.
  *
  * @param commitComments
  * @return
  */
 private boolean hasReply(List<CommitComment> commitComments) {
   return commitComments.size() > 1;
 }
Exemple #11
0
 /**
  * 답글 목록을 반환한다.
  *
  * @param commitComments
  * @return
  */
 private List<CommitComment> replies(List<CommitComment> commitComments) {
   return commitComments.subList(1, commitComments.size());
 }
Exemple #12
0
 public int getLackingPoints() {
   return toProject.defaultReviewPoint - reviewers.size();
 }
Exemple #13
0
 public boolean isReviewed() {
   return reviewers.size() >= toProject.defaultReviewPoint;
 }
Exemple #14
0
 /**
  * @return
  * @see models.AbstractPosting#computeNumOfComments()
  */
 public int computeNumOfComments() {
   return comments.size();
 }