コード例 #1
0
  private Collection adaptCollectionDetailsInfoToCollection(
      CollectionDetailsInfo collectionInfo, UserAccount user) {

    Collection collection = new Collection();
    collection.setDurationHours(collectionInfo.getDurationHours());
    collection.setCode(collectionInfo.getCode());
    collection.setName(collectionInfo.getName());
    collection.setClassifierEnabled(false);
    collection.setProvider(CollectionType.valueOf(collectionInfo.getProvider()));
    collection.setOwner(user);
    collection.setStatus(CollectionStatus.NOT_RUNNING);
    collection.setPubliclyListed(true); // TODO: change default behavior to user choice

    collection.setGeoR(collectionInfo.getGeoR());
    collection.setGeo(collectionInfo.getGeo());
    collection.setTrack(collectionInfo.getTrack());
    collection.setCrisisType(crisisTypeService.getById(collectionInfo.getCrisisType()));
    collection.setFollow(collectionInfo.getFollow());
    collection.setLangFilters(collectionInfo.getLangFilters());
    collection.setMicromappersEnabled(Boolean.FALSE);
    collection.setProvider(CollectionType.valueOf(collectionInfo.getProvider()));
    collection.setPurpose(collectionInfo.getPurpose());
    collection.setFetchInterval(collectionInfo.getFetchInterval());
    collection.setFetchFrom(collectionInfo.getFetchFrom());

    if (CollectionType.SMS.equals(collectionInfo.getProvider())) {
      collection.setTrack(null);
      collection.setLangFilters(null);
      collection.setGeo(null);
      collection.setFollow(null);
    }

    Timestamp now = new Timestamp(System.currentTimeMillis());
    collection.setCreatedAt(now);
    collection.setUpdatedAt(now);
    return collection;
  }