@Test public void checkStartUpResellerAdd() { Person2 person = personRepo.findOne("atang"); PostalAddress2 inputAddr = new PostalAddress2(); inputAddr.setId(UUID.fromString("ea27abc2-af4d-4791-aac5-c97f03bd2a17")); inputAddr.setName("batman"); inputAddr.setStreet("fasdf asdf"); inputAddr.setCity("Bandung"); inputAddr.setPostalCode("12345"); inputAddr.setProvince("Jawa Barat"); inputAddr.setCountry("Indonesia"); inputAddr.setCountryCode("ID"); inputAddr.setPrimaryMobile("08912333377"); inputAddr.setPrimaryEmail("batman@gmail.com"); inputAddr.setPrimary(Boolean.FALSE); inputAddr.setPrimaryBilling(Boolean.FALSE); inputAddr.setPrimaryShipping(Boolean.FALSE); inputAddr.setDistrict("Andir"); inputAddr.setStartupReseller(Boolean.TRUE); inputAddr.setStartupResellerId("atang"); inputAddr.setStartupResellerRegistartion(new Date(1539795600000L)); java.util.Optional<PostalAddress2> resellerAddr = person.getAddresses().stream().filter(new java.util.function.Predicate<PostalAddress2>() { @Override public boolean test(PostalAddress2 t) { return t.isEqualWith(inputAddr) && t.isStartupReseller(); } }).findFirst(); if (!resellerAddr.isPresent()) { System.out.println("gak ade"); } else { Date regDate = resellerAddr.get().getStartupResellerRegistartion(); boolean lessThan3Month = regDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate().isBefore( LocalDate.now().minusMonths(3) ); System.out.println(!lessThan3Month); } }
@Override public ImmutableList<PostalAddress2> getAddresses(String id) { final BasicDBObject query = new BasicDBObject("_id", id); final BasicDBObject fields = new BasicDBObject("addresses", 1); final DBObject dbObj = findOneSecondary(query, fields, "getAddresses", id); if (dbObj == null) { return ImmutableList.of(); } final ImmutableList.Builder<PostalAddress2> bList = ImmutableList.builder(); if (dbObj.containsField("addresses")) { final BasicDBList objAddresses = (BasicDBList) dbObj.get("addresses"); objAddresses.forEach(new Consumer<Object>() { @Override public void accept(Object t) { final DBObject objAddress = (DBObject) t; final PostalAddress2 address = new PostalAddress2(); if (objAddress.containsField("city")) { address.setCity(String.valueOf(objAddress.get("city"))); } if (objAddress.containsField("country")) { address.setCountry(String.valueOf(objAddress.get("country"))); } if (objAddress.containsField("countryCode")) { address.setCountryCode(String.valueOf(objAddress.get("countryCode"))); } if (objAddress.containsField("description")) { address.setDescription(String.valueOf(objAddress.get("description"))); } if (objAddress.containsField("district")) { address.setDistrict(String.valueOf(objAddress.get("district"))); } if (objAddress.containsField("emails")) { final BasicDBList objEmails = (BasicDBList) objAddress.get("emails"); address.setEmails(objEmails.stream().map(new java.util.function.Function<Object, String>() { @Override public String apply(Object t) { return String.valueOf(t); } }).collect(Collectors.toList())); } if (objAddress.containsField("homePhones")) { final BasicDBList objHomePhones = (BasicDBList) objAddress.get("homePhones"); address.setHomePhones(objHomePhones.stream().map(new java.util.function.Function<Object, String>() { @Override public String apply(Object t) { return String.valueOf(t); } }).collect(Collectors.toList())); } if (objAddress.containsField("id")) { address.setId(UUID.fromString(String.valueOf(objAddress.get("id")))); } if (objAddress.containsField("jneAreaCode")) { address.setJneAreaCode(String.valueOf(objAddress.get("jneAreaCode"))); } if (objAddress.containsField("mobiles")) { final BasicDBList objMobiles = (BasicDBList) objAddress.get("mobiles"); address.setMobiles(objMobiles.stream().map(new java.util.function.Function<Object, String>() { @Override public String apply(Object t) { return String.valueOf(t); } }).collect(Collectors.toList())); } if (objAddress.containsField("name")) { address.setName(String.valueOf(objAddress.get("name"))); } if (objAddress.containsField("organization")) { address.setOrganization(String.valueOf(objAddress.get("organization"))); } if (objAddress.containsField("phones")) { final BasicDBList objPhones = (BasicDBList) objAddress.get("phones"); address.setPhones(objPhones.stream().map(new java.util.function.Function<Object, String>() { @Override public String apply(Object t) { return String.valueOf(t); } }).collect(Collectors.toList())); } if (objAddress.containsField("postalCode")) { address.setPostalCode(String.valueOf(objAddress.get("postalCode"))); } if (objAddress.containsField("primary")) { address.setPrimary(Boolean.valueOf(String.valueOf(objAddress.get("primary")))); } if (objAddress.containsField("primaryBilling")) { address.setPrimaryBilling(Boolean.valueOf(String.valueOf(objAddress.get("primaryBilling")))); } if (objAddress.containsField("primaryEmail")) { address.setPrimaryEmail(String.valueOf(objAddress.get("primaryEmail"))); } if (objAddress.containsField("primaryHomePhone")) { address.setPrimaryHomePhone(String.valueOf(objAddress.get("primaryHomePhone"))); } if (objAddress.containsField("primaryMobile")) { address.setPrimaryMobile(String.valueOf(objAddress.get("primaryMobile"))); } if (objAddress.containsField("primaryPhone")) { address.setPrimaryPhone(String.valueOf(objAddress.get("primaryPhone"))); } if (objAddress.containsField("primaryShipping")) { address.setPrimaryShipping(Boolean.valueOf(String.valueOf(objAddress.get("primaryShipping")))); } if (objAddress.containsField("primaryWorkPhone")) { address.setPrimaryWorkPhone(String.valueOf(objAddress.get("primaryWorkPhone"))); } if (objAddress.containsField("province")) { address.setProvince(String.valueOf(objAddress.get("province"))); } if (objAddress.containsField("street")) { address.setStreet(String.valueOf(objAddress.get("street"))); } if (objAddress.containsField("validationTime")) { address.setValidationTime(new DateTime(objAddress.get("validationTime"))); } if (objAddress.containsField("validationTime_zone")) { address.setValidationTime_zone(DateTimeZone.forID(String.valueOf(objAddress.get("validationTime_zone")))); } if (objAddress.containsField("workPhones")) { final BasicDBList objWorkPhones = (BasicDBList) objAddress.get("workPhones"); address.setWorkPhones(objWorkPhones.stream().map(new java.util.function.Function<Object, String>() { @Override public String apply(Object t) { return String.valueOf(t); } }).collect(Collectors.toList())); } bList.add(address); } }); } return bList.build(); }
MongoPersonRepository extends MongoRepositoryBase<Person2> implements PersonRepository { @Override public ImmutableList<PostalAddress2> getAddresses(String id) { final BasicDBObject query = new BasicDBObject("_id", id); final BasicDBObject fields = new BasicDBObject("addresses", 1); final DBObject dbObj = findOneSecondary(query, fields, "getAddresses", id); if (dbObj == null) { return ImmutableList.of(); } final ImmutableList.Builder<PostalAddress2> bList = ImmutableList.builder(); if (dbObj.containsField("addresses")) { final BasicDBList objAddresses = (BasicDBList) dbObj.get("addresses"); objAddresses.forEach(new Consumer<Object>() { @Override public void accept(Object t) { final DBObject objAddress = (DBObject) t; final PostalAddress2 address = new PostalAddress2(); if (objAddress.containsField("city")) { address.setCity(String.valueOf(objAddress.get("city"))); } if (objAddress.containsField("country")) { address.setCountry(String.valueOf(objAddress.get("country"))); } if (objAddress.containsField("countryCode")) { address.setCountryCode(String.valueOf(objAddress.get("countryCode"))); } if (objAddress.containsField("description")) { address.setDescription(String.valueOf(objAddress.get("description"))); } if (objAddress.containsField("district")) { address.setDistrict(String.valueOf(objAddress.get("district"))); } if (objAddress.containsField("emails")) { final BasicDBList objEmails = (BasicDBList) objAddress.get("emails"); address.setEmails(objEmails.stream().map(new java.util.function.Function<Object, String>() { @Override public String apply(Object t) { return String.valueOf(t); } }).collect(Collectors.toList())); } if (objAddress.containsField("homePhones")) { final BasicDBList objHomePhones = (BasicDBList) objAddress.get("homePhones"); address.setHomePhones(objHomePhones.stream().map(new java.util.function.Function<Object, String>() { @Override public String apply(Object t) { return String.valueOf(t); } }).collect(Collectors.toList())); } if (objAddress.containsField("id")) { address.setId(UUID.fromString(String.valueOf(objAddress.get("id")))); } if (objAddress.containsField("jneAreaCode")) { address.setJneAreaCode(String.valueOf(objAddress.get("jneAreaCode"))); } if (objAddress.containsField("mobiles")) { final BasicDBList objMobiles = (BasicDBList) objAddress.get("mobiles"); address.setMobiles(objMobiles.stream().map(new java.util.function.Function<Object, String>() { @Override public String apply(Object t) { return String.valueOf(t); } }).collect(Collectors.toList())); } if (objAddress.containsField("name")) { address.setName(String.valueOf(objAddress.get("name"))); } if (objAddress.containsField("organization")) { address.setOrganization(String.valueOf(objAddress.get("organization"))); } if (objAddress.containsField("phones")) { final BasicDBList objPhones = (BasicDBList) objAddress.get("phones"); address.setPhones(objPhones.stream().map(new java.util.function.Function<Object, String>() { @Override public String apply(Object t) { return String.valueOf(t); } }).collect(Collectors.toList())); } if (objAddress.containsField("postalCode")) { address.setPostalCode(String.valueOf(objAddress.get("postalCode"))); } if (objAddress.containsField("primary")) { address.setPrimary(Boolean.valueOf(String.valueOf(objAddress.get("primary")))); } if (objAddress.containsField("primaryBilling")) { address.setPrimaryBilling(Boolean.valueOf(String.valueOf(objAddress.get("primaryBilling")))); } if (objAddress.containsField("primaryEmail")) { address.setPrimaryEmail(String.valueOf(objAddress.get("primaryEmail"))); } if (objAddress.containsField("primaryHomePhone")) { address.setPrimaryHomePhone(String.valueOf(objAddress.get("primaryHomePhone"))); } if (objAddress.containsField("primaryMobile")) { address.setPrimaryMobile(String.valueOf(objAddress.get("primaryMobile"))); } if (objAddress.containsField("primaryPhone")) { address.setPrimaryPhone(String.valueOf(objAddress.get("primaryPhone"))); } if (objAddress.containsField("primaryShipping")) { address.setPrimaryShipping(Boolean.valueOf(String.valueOf(objAddress.get("primaryShipping")))); } if (objAddress.containsField("primaryWorkPhone")) { address.setPrimaryWorkPhone(String.valueOf(objAddress.get("primaryWorkPhone"))); } if (objAddress.containsField("province")) { address.setProvince(String.valueOf(objAddress.get("province"))); } if (objAddress.containsField("street")) { address.setStreet(String.valueOf(objAddress.get("street"))); } if (objAddress.containsField("validationTime")) { address.setValidationTime(new DateTime(objAddress.get("validationTime"))); } if (objAddress.containsField("validationTime_zone")) { address.setValidationTime_zone(DateTimeZone.forID(String.valueOf(objAddress.get("validationTime_zone")))); } if (objAddress.containsField("workPhones")) { final BasicDBList objWorkPhones = (BasicDBList) objAddress.get("workPhones"); address.setWorkPhones(objWorkPhones.stream().map(new java.util.function.Function<Object, String>() { @Override public String apply(Object t) { return String.valueOf(t); } }).collect(Collectors.toList())); } bList.add(address); } }); } return bList.build(); } }
MongoPersonRepository extends MongoRepositoryBase<Person2> implements PersonRepository { @Override public ImmutableList<PostalAddress2> getAddresses(String id) { final BasicDBObject query = new BasicDBObject("_id", id); final BasicDBObject fields = new BasicDBObject("addresses", 1); final DBObject dbObj = findOneSecondary(query, fields, "getAddresses", id); if (dbObj == null) { return ImmutableList.of(); } final ImmutableList.Builder<PostalAddress2> bList = ImmutableList.builder(); if (dbObj.containsField("addresses")) { final BasicDBList objAddresses = (BasicDBList) dbObj.get("addresses"); objAddresses.forEach(new Consumer<Object>() { @Override public void accept(Object t) { final DBObject objAddress = (DBObject) t; final PostalAddress2 address = new PostalAddress2(); if (objAddress.containsField("city")) { address.setCity(String.valueOf(objAddress.get("city"))); } if (objAddress.containsField("country")) { address.setCountry(String.valueOf(objAddress.get("country"))); } if (objAddress.containsField("countryCode")) { address.setCountryCode(String.valueOf(objAddress.get("countryCode"))); } if (objAddress.containsField("description")) { address.setDescription(String.valueOf(objAddress.get("description"))); } if (objAddress.containsField("district")) { address.setDistrict(String.valueOf(objAddress.get("district"))); } if (objAddress.containsField("emails")) { final BasicDBList objEmails = (BasicDBList) objAddress.get("emails"); address.setEmails(objEmails.stream().map(new java.util.function.Function<Object, String>() { @Override public String apply(Object t) { return String.valueOf(t); } }).collect(Collectors.toList())); } if (objAddress.containsField("homePhones")) { final BasicDBList objHomePhones = (BasicDBList) objAddress.get("homePhones"); address.setHomePhones(objHomePhones.stream().map(new java.util.function.Function<Object, String>() { @Override public String apply(Object t) { return String.valueOf(t); } }).collect(Collectors.toList())); } if (objAddress.containsField("id")) { address.setId(UUID.fromString(String.valueOf(objAddress.get("id")))); } if (objAddress.containsField("jneAreaCode")) { address.setJneAreaCode(String.valueOf(objAddress.get("jneAreaCode"))); } if (objAddress.containsField("mobiles")) { final BasicDBList objMobiles = (BasicDBList) objAddress.get("mobiles"); address.setMobiles(objMobiles.stream().map(new java.util.function.Function<Object, String>() { @Override public String apply(Object t) { return String.valueOf(t); } }).collect(Collectors.toList())); } if (objAddress.containsField("name")) { address.setName(String.valueOf(objAddress.get("name"))); } if (objAddress.containsField("organization")) { address.setOrganization(String.valueOf(objAddress.get("organization"))); } if (objAddress.containsField("phones")) { final BasicDBList objPhones = (BasicDBList) objAddress.get("phones"); address.setPhones(objPhones.stream().map(new java.util.function.Function<Object, String>() { @Override public String apply(Object t) { return String.valueOf(t); } }).collect(Collectors.toList())); } if (objAddress.containsField("postalCode")) { address.setPostalCode(String.valueOf(objAddress.get("postalCode"))); } if (objAddress.containsField("primary")) { address.setPrimary(Boolean.valueOf(String.valueOf(objAddress.get("primary")))); } if (objAddress.containsField("primaryBilling")) { address.setPrimaryBilling(Boolean.valueOf(String.valueOf(objAddress.get("primaryBilling")))); } if (objAddress.containsField("primaryEmail")) { address.setPrimaryEmail(String.valueOf(objAddress.get("primaryEmail"))); } if (objAddress.containsField("primaryHomePhone")) { address.setPrimaryHomePhone(String.valueOf(objAddress.get("primaryHomePhone"))); } if (objAddress.containsField("primaryMobile")) { address.setPrimaryMobile(String.valueOf(objAddress.get("primaryMobile"))); } if (objAddress.containsField("primaryPhone")) { address.setPrimaryPhone(String.valueOf(objAddress.get("primaryPhone"))); } if (objAddress.containsField("primaryShipping")) { address.setPrimaryShipping(Boolean.valueOf(String.valueOf(objAddress.get("primaryShipping")))); } if (objAddress.containsField("primaryWorkPhone")) { address.setPrimaryWorkPhone(String.valueOf(objAddress.get("primaryWorkPhone"))); } if (objAddress.containsField("province")) { address.setProvince(String.valueOf(objAddress.get("province"))); } if (objAddress.containsField("street")) { address.setStreet(String.valueOf(objAddress.get("street"))); } if (objAddress.containsField("validationTime")) { address.setValidationTime(new DateTime(objAddress.get("validationTime"))); } if (objAddress.containsField("validationTime_zone")) { address.setValidationTime_zone(DateTimeZone.forID(String.valueOf(objAddress.get("validationTime_zone")))); } if (objAddress.containsField("workPhones")) { final BasicDBList objWorkPhones = (BasicDBList) objAddress.get("workPhones"); address.setWorkPhones(objWorkPhones.stream().map(new java.util.function.Function<Object, String>() { @Override public String apply(Object t) { return String.valueOf(t); } }).collect(Collectors.toList())); } bList.add(address); } }); } return bList.build(); } MongoPersonRepository(String tenantId, @Nullable CacheManager cacheMgr, String mongoUri,
			boolean migrationEnabled, boolean autoExplainSlow); }
MongoPersonRepository extends MongoRepositoryBase<Person2> implements PersonRepository { @Override public ImmutableList<PostalAddress2> getAddresses(String id) { final BasicDBObject query = new BasicDBObject("_id", id); final BasicDBObject fields = new BasicDBObject("addresses", 1); final DBObject dbObj = findOneSecondary(query, fields, "getAddresses", id); if (dbObj == null) { return ImmutableList.of(); } final ImmutableList.Builder<PostalAddress2> bList = ImmutableList.builder(); if (dbObj.containsField("addresses")) { final BasicDBList objAddresses = (BasicDBList) dbObj.get("addresses"); objAddresses.forEach(new Consumer<Object>() { @Override public void accept(Object t) { final DBObject objAddress = (DBObject) t; final PostalAddress2 address = new PostalAddress2(); if (objAddress.containsField("city")) { address.setCity(String.valueOf(objAddress.get("city"))); } if (objAddress.containsField("country")) { address.setCountry(String.valueOf(objAddress.get("country"))); } if (objAddress.containsField("countryCode")) { address.setCountryCode(String.valueOf(objAddress.get("countryCode"))); } if (objAddress.containsField("description")) { address.setDescription(String.valueOf(objAddress.get("description"))); } if (objAddress.containsField("district")) { address.setDistrict(String.valueOf(objAddress.get("district"))); } if (objAddress.containsField("emails")) { final BasicDBList objEmails = (BasicDBList) objAddress.get("emails"); address.setEmails(objEmails.stream().map(new java.util.function.Function<Object, String>() { @Override public String apply(Object t) { return String.valueOf(t); } }).collect(Collectors.toList())); } if (objAddress.containsField("homePhones")) { final BasicDBList objHomePhones = (BasicDBList) objAddress.get("homePhones"); address.setHomePhones(objHomePhones.stream().map(new java.util.function.Function<Object, String>() { @Override public String apply(Object t) { return String.valueOf(t); } }).collect(Collectors.toList())); } if (objAddress.containsField("id")) { address.setId(UUID.fromString(String.valueOf(objAddress.get("id")))); } if (objAddress.containsField("jneAreaCode")) { address.setJneAreaCode(String.valueOf(objAddress.get("jneAreaCode"))); } if (objAddress.containsField("mobiles")) { final BasicDBList objMobiles = (BasicDBList) objAddress.get("mobiles"); address.setMobiles(objMobiles.stream().map(new java.util.function.Function<Object, String>() { @Override public String apply(Object t) { return String.valueOf(t); } }).collect(Collectors.toList())); } if (objAddress.containsField("name")) { address.setName(String.valueOf(objAddress.get("name"))); } if (objAddress.containsField("organization")) { address.setOrganization(String.valueOf(objAddress.get("organization"))); } if (objAddress.containsField("phones")) { final BasicDBList objPhones = (BasicDBList) objAddress.get("phones"); address.setPhones(objPhones.stream().map(new java.util.function.Function<Object, String>() { @Override public String apply(Object t) { return String.valueOf(t); } }).collect(Collectors.toList())); } if (objAddress.containsField("postalCode")) { address.setPostalCode(String.valueOf(objAddress.get("postalCode"))); } if (objAddress.containsField("primary")) { address.setPrimary(Boolean.valueOf(String.valueOf(objAddress.get("primary")))); } if (objAddress.containsField("primaryBilling")) { address.setPrimaryBilling(Boolean.valueOf(String.valueOf(objAddress.get("primaryBilling")))); } if (objAddress.containsField("primaryEmail")) { address.setPrimaryEmail(String.valueOf(objAddress.get("primaryEmail"))); } if (objAddress.containsField("primaryHomePhone")) { address.setPrimaryHomePhone(String.valueOf(objAddress.get("primaryHomePhone"))); } if (objAddress.containsField("primaryMobile")) { address.setPrimaryMobile(String.valueOf(objAddress.get("primaryMobile"))); } if (objAddress.containsField("primaryPhone")) { address.setPrimaryPhone(String.valueOf(objAddress.get("primaryPhone"))); } if (objAddress.containsField("primaryShipping")) { address.setPrimaryShipping(Boolean.valueOf(String.valueOf(objAddress.get("primaryShipping")))); } if (objAddress.containsField("primaryWorkPhone")) { address.setPrimaryWorkPhone(String.valueOf(objAddress.get("primaryWorkPhone"))); } if (objAddress.containsField("province")) { address.setProvince(String.valueOf(objAddress.get("province"))); } if (objAddress.containsField("street")) { address.setStreet(String.valueOf(objAddress.get("street"))); } if (objAddress.containsField("validationTime")) { address.setValidationTime(new DateTime(objAddress.get("validationTime"))); } if (objAddress.containsField("validationTime_zone")) { address.setValidationTime_zone(DateTimeZone.forID(String.valueOf(objAddress.get("validationTime_zone")))); } if (objAddress.containsField("workPhones")) { final BasicDBList objWorkPhones = (BasicDBList) objAddress.get("workPhones"); address.setWorkPhones(objWorkPhones.stream().map(new java.util.function.Function<Object, String>() { @Override public String apply(Object t) { return String.valueOf(t); } }).collect(Collectors.toList())); } bList.add(address); } }); } return bList.build(); } MongoPersonRepository(String tenantId, @Nullable CacheManager cacheMgr, String mongoUri,
			boolean migrationEnabled, boolean autoExplainSlow); @Override @Nullable Person2 findOneBySlug(StatusMask statusMask, String upSlug); @Override Existence<String> existsBySlug(StatusMask statusMask, String upSlug); @Override Existence<String> existsBySlugCacheable(StatusMask statusMask, String upSlug); @Override Person2 findOneByFacebook(@Nullable Long facebookId, @Nullable String facebookUsername); @Override @Nullable Person2 findOneByEmail(StatusMask statusMask, @Nullable String email); @Override @Nullable Person2 findOneByEmail(AccountStatus status, String email); @Override boolean isExistsByEmail(StatusMask statusMask, String email); @Override Optional<String> getIdByEmail(StatusMask statusMask, String email); @Override @Nullable Person2 findOneById(StatusMask statusMask, @Nullable String id); @Override @Nullable Person2 findOneByMobileOrPhoneNumber(StatusMask statusMask, @Nullable String phoneNumber); @Override boolean isMobilePhoneNumberAlreadyRegistered(StatusMask statusMask, String phoneNumber); @Override Optional<String> getIdByMobileOrPhoneNumber(StatusMask statusMask, String phoneNumber); @Override @Nullable Person2 findOneByTwitter(@Nullable Long twitterId, @Nullable String twitterScreenName); @Override @Nullable Person2 findOneByClientAccessToken(@Nullable String clientAccessToken); @Override Page<Person2> findBySearchText(StatusMask statusMask, @Nullable String searchText, Pageable pageable); @Override long countBySearchText(StatusMask statusMask, String searchText); @Override Page<Person2> findAll(StatusMask statusMask, Pageable pageable); @Override Page<Person2> findAll(StatusMask statusMask, Projection projection, Pageable pageable); @Override long count(StatusMask statusMask); @Override Person2 findOneActive(String personId); @Override S lookupOne(StatusMask statusMask, LookupKey lookupKey, K key); @Override Map<K, Try<S>> lookupAll(StatusMask statusMask,
			LookupKey lookupKey, Collection<K> keys); @Override Map<K, Existence<K>> checkExistsAll(StatusMask statusMask, LookupKey lookupKey,
			Collection<K> keys); @Override Existence<K> checkExists(StatusMask statusMask, LookupKey lookupKey, K key); @Override TrashResult trash(Person2 entity); @Override TrashResult trashById(String id); @Override Map<String, Try<TrashResult>> trashAll(Collection<Person2> entities); @Override Map<String, Try<TrashResult>> trashAllByIds(Collection<String> ids); @Override UntrashResult untrash(Person2 entity); @Override UntrashResult untrashById(String id); @Override Map<String, Try<UntrashResult>> untrashAll(Collection<Person2> entities); @Override Map<String, Try<UntrashResult>> untrashAllByIds(Collection<String> ids); @Override List<Person2> findAll(StatusMask statusMask, Collection<String> ids); @Override Page<Person2> findAll(StatusMask statusMask, Collection<String> ids, Pageable pageable); @Override List<Person2> findAllBySecRoleIds(StatusMask statusMask, Collection<String> secRoleIds); @Override boolean hasMatchWithSecRoleIds(String personId, Collection<String> secRoleIds); @Override List<Person2> findAllByCustomerRoleIds(StatusMask statusMask, Collection<String> customerRoleIds); @Override Page<Person2> findAllByCustomerRoleIds(StatusMask statusMask, Collection<String> customerRoleIds,
			Pageable pageable); @Override long countAllByCustomerRolesIds(StatusMask statusMask, Collection<String> customerRoleIds); @Override Page<Person2> findAllByKeywordAndStatus(String keyword, Collection<AccountStatus> accountStatuses,
			Pageable pageable); @Override Page<Person2> findAllByKeywordAndRoles(String keyword, Collection<AccountStatus> accountStatuses,
			CustomerRole2 customerRole, Collection<String> securityRoleIds, Pageable pageable); @Override long countAllByKeywordAndRoles(String keyword, Collection<AccountStatus> accountStatuses,
			CustomerRole2 customerRole, Collection<String> securityRoleIds); @Override Page<Person2> findAll(Collection<AccountStatus> accountStatuses, Pageable pageable); @Override long countBySearchText(Collection<AccountStatus> accountStatuses, String searchText); @Override long countByStatuses(Collection<AccountStatus> accountStatuses); @Override long countByFacebook(); @Override boolean existByCustomerRoleIds(StatusMask statusMask, Collection<String> customerRoleIds); @Override void setNullCustomerRole(Collection<String> customerRoleIds); @Override String getCustomerRoleByPersonId(String personId); @Override ImmutableSet<String> findAllSlugsByStatus(StatusMask statusMask); @Override ImmutableSet<String> findAllSlugsByStatus(StatusMask statusMask, Pageable pageable); @Override @Nullable Person2 getZendeskUserId(String email); @Override Long getZendeskUserIdByPersonId(String personId); @Override Page<Person2> findAllByEmailExists(StatusMask statusMask, Pageable pageable); @Override Page<Person2> findAllByEmailExists(DateTime starTime, DateTime endTime, StatusMask statusMask,
			Pageable pageable); @Override List<String> findAllIdsByCustomerRoleId(StatusMask statusMask, String customerRoleId); @Override Optional<String> getCustomerRole(@Nonnull String personId); @Override boolean existsByEmail(String email); @Override boolean existsByEmailAndStatus(String email, AccountStatus status); @Override ImmutableList<AccountStatus> getStatusesByEmail(String email); String findJneAreaCode(String district, String city, String province, String country); @Override double getPerformanceValue(String id); @Override boolean updatePerformanceValues(Map<String, Double> upPerformanceMap); @Override Page<Person2> findAllWhereCustomerRoleValidThruNotNull(StatusMask statusMask, Pageable pageable); @SuppressWarnings("deprecation") @Override void removeFcmToken(String userId, String oldFirebaseCloudMessagingToken); @Override boolean addPrimaryEmail(String id, String primaryEmail); @Override boolean addPrimaryMobileNumber(String id, String mobileNumber); @Override @Nullable PersonInfo2 findOneAsInfo(String id); @Override ImmutableList<PostalAddress2> getAddresses(String id); @Override void setJneAreaCode(String id, UUID addressId, String areaCode); @Override void addAddress(String id, PostalAddress2 address); @Override PostalAddress2 getBillingAddress(String id); @Override void modifyAddress(String personId, PostalAddress2 postalAddress); @Override ImmutableSet<String> getFcmTokens(String id); @Override PostalAddress2 getShippingAddress(String id); @Override ImmutableMap<String, String> findCustomerRoleIdMap(Collection<String> personIds); @Override void setAddressToResellerStartUp(String personId, UUID addressId, String startUpId, Date regDate); @Override Map<String, Double> getPerformanceValue(Collection<String> ids); @Override List<Performance> getPerformance(Collection<String> ids); @Override Performance getPerformance(String id); }
MongoPersonRepository extends MongoRepositoryBase<Person2> implements PersonRepository { @Override public ImmutableList<PostalAddress2> getAddresses(String id) { final BasicDBObject query = new BasicDBObject("_id", id); final BasicDBObject fields = new BasicDBObject("addresses", 1); final DBObject dbObj = findOneSecondary(query, fields, "getAddresses", id); if (dbObj == null) { return ImmutableList.of(); } final ImmutableList.Builder<PostalAddress2> bList = ImmutableList.builder(); if (dbObj.containsField("addresses")) { final BasicDBList objAddresses = (BasicDBList) dbObj.get("addresses"); objAddresses.forEach(new Consumer<Object>() { @Override public void accept(Object t) { final DBObject objAddress = (DBObject) t; final PostalAddress2 address = new PostalAddress2(); if (objAddress.containsField("city")) { address.setCity(String.valueOf(objAddress.get("city"))); } if (objAddress.containsField("country")) { address.setCountry(String.valueOf(objAddress.get("country"))); } if (objAddress.containsField("countryCode")) { address.setCountryCode(String.valueOf(objAddress.get("countryCode"))); } if (objAddress.containsField("description")) { address.setDescription(String.valueOf(objAddress.get("description"))); } if (objAddress.containsField("district")) { address.setDistrict(String.valueOf(objAddress.get("district"))); } if (objAddress.containsField("emails")) { final BasicDBList objEmails = (BasicDBList) objAddress.get("emails"); address.setEmails(objEmails.stream().map(new java.util.function.Function<Object, String>() { @Override public String apply(Object t) { return String.valueOf(t); } }).collect(Collectors.toList())); } if (objAddress.containsField("homePhones")) { final BasicDBList objHomePhones = (BasicDBList) objAddress.get("homePhones"); address.setHomePhones(objHomePhones.stream().map(new java.util.function.Function<Object, String>() { @Override public String apply(Object t) { return String.valueOf(t); } }).collect(Collectors.toList())); } if (objAddress.containsField("id")) { address.setId(UUID.fromString(String.valueOf(objAddress.get("id")))); } if (objAddress.containsField("jneAreaCode")) { address.setJneAreaCode(String.valueOf(objAddress.get("jneAreaCode"))); } if (objAddress.containsField("mobiles")) { final BasicDBList objMobiles = (BasicDBList) objAddress.get("mobiles"); address.setMobiles(objMobiles.stream().map(new java.util.function.Function<Object, String>() { @Override public String apply(Object t) { return String.valueOf(t); } }).collect(Collectors.toList())); } if (objAddress.containsField("name")) { address.setName(String.valueOf(objAddress.get("name"))); } if (objAddress.containsField("organization")) { address.setOrganization(String.valueOf(objAddress.get("organization"))); } if (objAddress.containsField("phones")) { final BasicDBList objPhones = (BasicDBList) objAddress.get("phones"); address.setPhones(objPhones.stream().map(new java.util.function.Function<Object, String>() { @Override public String apply(Object t) { return String.valueOf(t); } }).collect(Collectors.toList())); } if (objAddress.containsField("postalCode")) { address.setPostalCode(String.valueOf(objAddress.get("postalCode"))); } if (objAddress.containsField("primary")) { address.setPrimary(Boolean.valueOf(String.valueOf(objAddress.get("primary")))); } if (objAddress.containsField("primaryBilling")) { address.setPrimaryBilling(Boolean.valueOf(String.valueOf(objAddress.get("primaryBilling")))); } if (objAddress.containsField("primaryEmail")) { address.setPrimaryEmail(String.valueOf(objAddress.get("primaryEmail"))); } if (objAddress.containsField("primaryHomePhone")) { address.setPrimaryHomePhone(String.valueOf(objAddress.get("primaryHomePhone"))); } if (objAddress.containsField("primaryMobile")) { address.setPrimaryMobile(String.valueOf(objAddress.get("primaryMobile"))); } if (objAddress.containsField("primaryPhone")) { address.setPrimaryPhone(String.valueOf(objAddress.get("primaryPhone"))); } if (objAddress.containsField("primaryShipping")) { address.setPrimaryShipping(Boolean.valueOf(String.valueOf(objAddress.get("primaryShipping")))); } if (objAddress.containsField("primaryWorkPhone")) { address.setPrimaryWorkPhone(String.valueOf(objAddress.get("primaryWorkPhone"))); } if (objAddress.containsField("province")) { address.setProvince(String.valueOf(objAddress.get("province"))); } if (objAddress.containsField("street")) { address.setStreet(String.valueOf(objAddress.get("street"))); } if (objAddress.containsField("validationTime")) { address.setValidationTime(new DateTime(objAddress.get("validationTime"))); } if (objAddress.containsField("validationTime_zone")) { address.setValidationTime_zone(DateTimeZone.forID(String.valueOf(objAddress.get("validationTime_zone")))); } if (objAddress.containsField("workPhones")) { final BasicDBList objWorkPhones = (BasicDBList) objAddress.get("workPhones"); address.setWorkPhones(objWorkPhones.stream().map(new java.util.function.Function<Object, String>() { @Override public String apply(Object t) { return String.valueOf(t); } }).collect(Collectors.toList())); } bList.add(address); } }); } return bList.build(); } MongoPersonRepository(String tenantId, @Nullable CacheManager cacheMgr, String mongoUri,
			boolean migrationEnabled, boolean autoExplainSlow); @Override @Nullable Person2 findOneBySlug(StatusMask statusMask, String upSlug); @Override Existence<String> existsBySlug(StatusMask statusMask, String upSlug); @Override Existence<String> existsBySlugCacheable(StatusMask statusMask, String upSlug); @Override Person2 findOneByFacebook(@Nullable Long facebookId, @Nullable String facebookUsername); @Override @Nullable Person2 findOneByEmail(StatusMask statusMask, @Nullable String email); @Override @Nullable Person2 findOneByEmail(AccountStatus status, String email); @Override boolean isExistsByEmail(StatusMask statusMask, String email); @Override Optional<String> getIdByEmail(StatusMask statusMask, String email); @Override @Nullable Person2 findOneById(StatusMask statusMask, @Nullable String id); @Override @Nullable Person2 findOneByMobileOrPhoneNumber(StatusMask statusMask, @Nullable String phoneNumber); @Override boolean isMobilePhoneNumberAlreadyRegistered(StatusMask statusMask, String phoneNumber); @Override Optional<String> getIdByMobileOrPhoneNumber(StatusMask statusMask, String phoneNumber); @Override @Nullable Person2 findOneByTwitter(@Nullable Long twitterId, @Nullable String twitterScreenName); @Override @Nullable Person2 findOneByClientAccessToken(@Nullable String clientAccessToken); @Override Page<Person2> findBySearchText(StatusMask statusMask, @Nullable String searchText, Pageable pageable); @Override long countBySearchText(StatusMask statusMask, String searchText); @Override Page<Person2> findAll(StatusMask statusMask, Pageable pageable); @Override Page<Person2> findAll(StatusMask statusMask, Projection projection, Pageable pageable); @Override long count(StatusMask statusMask); @Override Person2 findOneActive(String personId); @Override S lookupOne(StatusMask statusMask, LookupKey lookupKey, K key); @Override Map<K, Try<S>> lookupAll(StatusMask statusMask,
			LookupKey lookupKey, Collection<K> keys); @Override Map<K, Existence<K>> checkExistsAll(StatusMask statusMask, LookupKey lookupKey,
			Collection<K> keys); @Override Existence<K> checkExists(StatusMask statusMask, LookupKey lookupKey, K key); @Override TrashResult trash(Person2 entity); @Override TrashResult trashById(String id); @Override Map<String, Try<TrashResult>> trashAll(Collection<Person2> entities); @Override Map<String, Try<TrashResult>> trashAllByIds(Collection<String> ids); @Override UntrashResult untrash(Person2 entity); @Override UntrashResult untrashById(String id); @Override Map<String, Try<UntrashResult>> untrashAll(Collection<Person2> entities); @Override Map<String, Try<UntrashResult>> untrashAllByIds(Collection<String> ids); @Override List<Person2> findAll(StatusMask statusMask, Collection<String> ids); @Override Page<Person2> findAll(StatusMask statusMask, Collection<String> ids, Pageable pageable); @Override List<Person2> findAllBySecRoleIds(StatusMask statusMask, Collection<String> secRoleIds); @Override boolean hasMatchWithSecRoleIds(String personId, Collection<String> secRoleIds); @Override List<Person2> findAllByCustomerRoleIds(StatusMask statusMask, Collection<String> customerRoleIds); @Override Page<Person2> findAllByCustomerRoleIds(StatusMask statusMask, Collection<String> customerRoleIds,
			Pageable pageable); @Override long countAllByCustomerRolesIds(StatusMask statusMask, Collection<String> customerRoleIds); @Override Page<Person2> findAllByKeywordAndStatus(String keyword, Collection<AccountStatus> accountStatuses,
			Pageable pageable); @Override Page<Person2> findAllByKeywordAndRoles(String keyword, Collection<AccountStatus> accountStatuses,
			CustomerRole2 customerRole, Collection<String> securityRoleIds, Pageable pageable); @Override long countAllByKeywordAndRoles(String keyword, Collection<AccountStatus> accountStatuses,
			CustomerRole2 customerRole, Collection<String> securityRoleIds); @Override Page<Person2> findAll(Collection<AccountStatus> accountStatuses, Pageable pageable); @Override long countBySearchText(Collection<AccountStatus> accountStatuses, String searchText); @Override long countByStatuses(Collection<AccountStatus> accountStatuses); @Override long countByFacebook(); @Override boolean existByCustomerRoleIds(StatusMask statusMask, Collection<String> customerRoleIds); @Override void setNullCustomerRole(Collection<String> customerRoleIds); @Override String getCustomerRoleByPersonId(String personId); @Override ImmutableSet<String> findAllSlugsByStatus(StatusMask statusMask); @Override ImmutableSet<String> findAllSlugsByStatus(StatusMask statusMask, Pageable pageable); @Override @Nullable Person2 getZendeskUserId(String email); @Override Long getZendeskUserIdByPersonId(String personId); @Override Page<Person2> findAllByEmailExists(StatusMask statusMask, Pageable pageable); @Override Page<Person2> findAllByEmailExists(DateTime starTime, DateTime endTime, StatusMask statusMask,
			Pageable pageable); @Override List<String> findAllIdsByCustomerRoleId(StatusMask statusMask, String customerRoleId); @Override Optional<String> getCustomerRole(@Nonnull String personId); @Override boolean existsByEmail(String email); @Override boolean existsByEmailAndStatus(String email, AccountStatus status); @Override ImmutableList<AccountStatus> getStatusesByEmail(String email); String findJneAreaCode(String district, String city, String province, String country); @Override double getPerformanceValue(String id); @Override boolean updatePerformanceValues(Map<String, Double> upPerformanceMap); @Override Page<Person2> findAllWhereCustomerRoleValidThruNotNull(StatusMask statusMask, Pageable pageable); @SuppressWarnings("deprecation") @Override void removeFcmToken(String userId, String oldFirebaseCloudMessagingToken); @Override boolean addPrimaryEmail(String id, String primaryEmail); @Override boolean addPrimaryMobileNumber(String id, String mobileNumber); @Override @Nullable PersonInfo2 findOneAsInfo(String id); @Override ImmutableList<PostalAddress2> getAddresses(String id); @Override void setJneAreaCode(String id, UUID addressId, String areaCode); @Override void addAddress(String id, PostalAddress2 address); @Override PostalAddress2 getBillingAddress(String id); @Override void modifyAddress(String personId, PostalAddress2 postalAddress); @Override ImmutableSet<String> getFcmTokens(String id); @Override PostalAddress2 getShippingAddress(String id); @Override ImmutableMap<String, String> findCustomerRoleIdMap(Collection<String> personIds); @Override void setAddressToResellerStartUp(String personId, UUID addressId, String startUpId, Date regDate); @Override Map<String, Double> getPerformanceValue(Collection<String> ids); @Override List<Performance> getPerformance(Collection<String> ids); @Override Performance getPerformance(String id);  }