public Map<String, Object> purveyDocument(Product entity, Tenant tenant) { Map<String, Object> source = Maps.newHashMap(); source.put("site", extractSourceFromEntity(tenant, tenant)); source.putAll(extractSourceFromEntity(entity, tenant)); List<Collection> collections = collectionStore.findAllForProduct(entity); List<String> collectionsSource = Lists.newArrayList(); for (Collection collection : collections) { collectionsSource.add(collection.getSlug()); } source.put("collections", collectionsSource); return source; } }
@Override public Collection createCollection(Collection entity) throws InvalidEntityException, EntityAlreadyExistsException { if (Strings.isNullOrEmpty(entity.getSlug())) { entity.setSlug(this.slugifier.slugify(entity.getTitle())); } this.collectionStore.get().create(entity); return this.findCollectionBySlug(entity.getSlug()); }
public boolean apply(final CollectionPositionedEntity input) { return input.getEntity().getSlug().equals(slug) && input.getEntity().getParentId().equals(parentId); } }).first().orNull();
public Map<String, Object> purveyDocument(Tenant tenant) { Preconditions.checkNotNull(tenant); this.dao = this.dbi.get().onDemand(CollectionDAO.class); Map<String, Object> extracted = extractSourceFromEntity(tenant, tenant); List<Collection> collections = dao.findAll("collection", tenant.getId()); List<Map<String, Object>> collectionsSource = Lists.newArrayList(); for (Collection collection : collections) { Map<String, Object> collectionSource = extractSourceFromEntity(collection, tenant); collectionSource .put("api_url", urlHelper.getContextPlatformURL("/marketplace/api/shop/" + tenant.getSlug() + "/collections/" + collection.getSlug()).toString()); collectionsSource.add(collectionSource); } extracted.put("collections", collectionsSource); return extracted; } }
put("slug", localized.getSlug()); put("title", localized.getTitle()); put("description", localized.getDescription());
output.println("- indexing " + tenant.getSlug() + ":" + collection.getSlug()); output.flush();
public void update(Collection collection) throws EntityDoesNotExistException, InvalidEntityException { this.dao.begin(); Collection originalCollection = this.dao.findBySlug(collection.getSlug(), getTenant()); if (originalCollection == null) { this.dao.commit(); throw new EntityDoesNotExistException(); } collection.setId(originalCollection.getId()); Integer updatedRows = this.dao.update(collection); this.dao.createOrUpdateAddons(collection); if (collection.getLocalizedVersions() != null && !collection.getLocalizedVersions().isEmpty()) { Map<Locale, Map<String, Object>> localizedVersions = collection.getLocalizedVersions(); for (Locale locale : localizedVersions.keySet()) { this.dao.createOrUpdateTranslation(collection.getId(), locale, localizedVersions.get(locale)); } } this.dao.commit(); if (updatedRows <= 0) { throw new StoreException("No rows was updated when updating collection"); } getObservationManager().notify(new EntityUpdatedEvent(), collection); }
public Collection create(Collection collection) throws EntityAlreadyExistsException, InvalidEntityException { if (this.dao.findBySlug(collection.getSlug(), getTenant(), collection.getParentId()) != null) { throw new EntityAlreadyExistsException(); } getObservationManager().notify(new EntityCreatingEvent(), collection); this.dao.begin(); UUID entityId = UUID.randomUUID(); collection.setId(entityId); this.dao.createEntity(collection, COLLECTION_TABLE_NAME, getTenant()); Integer lastIndex = this.dao.lastPosition(getTenant()); this.dao.create(lastIndex == null ? 0 : ++lastIndex, collection); // this.dao.insertTranslations(entityId, collection.getTranslations()); this.dao.createOrUpdateAddons(collection); this.dao.commit(); getObservationManager().notify(new EntityCreatedEvent(), collection); return collection; }