@Override public Collection<CatalogVersionModel> findCatalogVersions( final String catalogId, final String version) { if (catalogId.equals(CATALOG_ID) && version.equals(CATALOGVERSION_ONE)) { final List<CatalogVersionModel> catalogVersions = new ArrayList<CatalogVersionModel>(); final CatalogModel catalog = new CatalogModel(); catalog.setId(CATALOG_ID); final CatalogVersionModel catalogVersion = new CatalogVersionModel(); catalogVersion.setCatalog(catalog); catalogVersion.setVersion(CATALOGVERSION_ONE); catalogVersions.add(catalogVersion); return catalogVersions; } else if (catalogId.equals(CATALOG_ID) && version.equals(CATALOGVERSION_TWO)) { final List<CatalogVersionModel> catalogVersions = new ArrayList<CatalogVersionModel>(); final CatalogModel catalog = new CatalogModel(); catalog.setId(CATALOG_ID); final CatalogVersionModel catalogVersion1 = new CatalogVersionModel(); catalogVersion1.setCatalog(catalog); catalogVersion1.setVersion(CATALOGVERSION_TWO); final CatalogVersionModel catalogVersion2 = new CatalogVersionModel(); catalogVersion2.setCatalog(catalog); catalogVersion2.setVersion(CATALOGVERSION_TWO); catalogVersions.add(catalogVersion1); catalogVersions.add(catalogVersion2); return catalogVersions; } return Collections.EMPTY_LIST; }
@Test public void searchRestrictionTest() { final UserGroupModel group = new UserGroupModel(); group.setUid("customergroup"); modelService.save(group); // create test user final UserModel user = new UserModel(); user.setUid(TEST_USER); // assign user to customergroup user.setGroups(Collections.singleton((PrincipalGroupModel) group)); modelService.save(user); // create test catalog final CatalogModel catalog = new CatalogModel(); catalog.setId(TEST_CATALOG); modelService.save(catalog); // create test catalog version final CatalogVersionModel catalogVersion = new CatalogVersionModel(); catalogVersion.setCatalog(catalog); catalogVersion.setVersion(TEST_VERSION); modelService.save(catalogVersion); // create test product final ProductModel product = new ProductModel(); product.setCode(TEST_PRODUCT); product.setCatalogVersion(catalogVersion); modelService.save(product); // set current user userService.setCurrentUser(user); // create search restriction commonI18NService.setCurrentLanguage(commonI18NService.getLanguage(LANG_EN)); final Map<String, String[]> params = new HashMap<String, String[]>(); params.put("customerreview.searchrestrictions.create", new String[] {"true"}); final SystemSetupContext ctx = new SystemSetupContext(params, Type.ESSENTIAL, Process.ALL, "customerreview"); customerReviewSystemSetup.createSearchRestrictions(ctx); // enable search restrictions searchRestrictionService.enableSearchRestrictions(); // make sure that number of customer reviews is 0 assertEquals( INVALID_NUMBER_OF_CUSTOMER_REVIEWS, Integer.valueOf(0), customerReviewService.getNumberOfReviews(product)); // create restricted customer review createCustomerReview(null, user, product, CustomerReviewApprovalType.PENDING); // create valid customer review createCustomerReview("headline", user, product, CustomerReviewApprovalType.APPROVED); // make sure that number of customer reviews is 1 assertEquals( INVALID_NUMBER_OF_CUSTOMER_REVIEWS, Integer.valueOf(1), customerReviewService.getNumberOfReviews(product)); // disable search restrictions searchRestrictionService.disableSearchRestrictions(); // make sure that number of customer reviews is 2 assertEquals( INVALID_NUMBER_OF_CUSTOMER_REVIEWS, Integer.valueOf(2), customerReviewService.getNumberOfReviews(product)); }
/** @return */ private CatalogVersionModel prepareCatalogVersion(final String version, final String catalogId) { final CatalogModel cat = new CatalogModel(); cat.setId(catalogId); final CatalogVersionModel templateCatalogVersion = new CatalogVersionModel(); templateCatalogVersion.setVersion(version); templateCatalogVersion.setCatalog(cat); return templateCatalogVersion; }
private CatalogVersionModel setUpCatalog(final String catId) { final CatalogModel catalog = modelService.create(CatalogModel.class); catalog.setId(catId); final CatalogVersionModel cv = modelService.create(CatalogVersionModel.class); cv.setVersion(catId + "Version"); cv.setCatalog(catalog); modelService.saveAll(catalog, cv); return cv; }
protected void executeSiteImport( final AddOnDataImportEventContext context, final ImportData importData, final ImpexMacroParameterData parameterData) { final CatalogModel productCatalog = getCatalogService().getCatalogForId(importData.getProductCatalogName() + "ProductCatalog"); context.setProductCatalog(productCatalog); populate(context, parameterData, getSelectedProductCatalogImpexMacroParametersPopulators()); final boolean productFilesImported = getAddonConfigDataImportService() .executeImport( parameterData.getConfigExtensionName(), AddonConfigDataImportType.PRODUCT, parameterData); if (productFilesImported && getAddonSystemSetupSupport() .getBooleanSystemSetupParameter( context.getSourceEvent().getContext(), AddOnSystemSetupSupport.IMPORT_SYNC_CATALOGS)) { getAddonSystemSetupSupport() .synchronizeProductCatalog(context.getSourceEvent().getContext(), productCatalog.getId()); } for (final String store : importData.getStoreNames()) { final BaseSiteModel baseSite = getBaseSiteService().getBaseSiteForUID(store); if (getSupportedChannels().contains(baseSite.getChannel())) { if (LOG.isInfoEnabled()) { LOG.info( "importing addon [" + parameterData.getConfigExtensionName() + "] configuration for [" + store + "]"); } context.setBaseSite(baseSite); populate(context, parameterData, getSelectedBaseSiteImpexMacroParametersPopulators()); if (baseSite instanceof CMSSiteModel) { final CMSSiteModel cmsSite = (CMSSiteModel) baseSite; for (final String contentCatalogName : importData.getContentCatalogNames()) { final CatalogModel contentCatalog = getCatalogService().getCatalogForId(contentCatalogName + "ContentCatalog"); if (cmsSite.getContentCatalogs().contains(contentCatalog)) { context.setContentCatalog((ContentCatalogModel) contentCatalog); populate( context, parameterData, getSelectedContentCatalogImpexMacroParametersPopulators()); final boolean contentFilesImported = getAddonConfigDataImportService() .executeImport( parameterData.getConfigExtensionName(), AddonConfigDataImportType.CONTENT, parameterData); if (contentFilesImported && getAddonSystemSetupSupport() .getBooleanSystemSetupParameter( context.getSourceEvent().getContext(), AddOnSystemSetupSupport.IMPORT_SYNC_CATALOGS)) { getAddonSystemSetupSupport() .synchronizeContentCatalog( context.getSourceEvent().getContext(), contentCatalog.getId()); } // import stores getAddonConfigDataImportService() .executeImport( parameterData.getConfigExtensionName(), AddonConfigDataImportType.STORE, parameterData); } } } final boolean solrFilesImported = getAddonConfigDataImportService() .executeImport( parameterData.getConfigExtensionName(), AddonConfigDataImportType.SOLR, parameterData); if ((solrFilesImported || productFilesImported) && getAddonSystemSetupSupport() .getBooleanSystemSetupParameter( context.getSourceEvent().getContext(), AddOnSystemSetupSupport.ACTIVATE_SOLR_CRON_JOBS)) { getAddonSystemSetupSupport() .executeSolrIndexerCronJob(parameterData.getSiteUid() + "Index", true); } } } }