当前位置: 首页>>代码示例>>Java>>正文


Java SiteImpl类代码示例

本文整理汇总了Java中org.broadleafcommerce.common.site.domain.SiteImpl的典型用法代码示例。如果您正苦于以下问题:Java SiteImpl类的具体用法?Java SiteImpl怎么用?Java SiteImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SiteImpl类属于org.broadleafcommerce.common.site.domain包,在下文中一共展示了SiteImpl类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readAllActiveSites

import org.broadleafcommerce.common.site.domain.SiteImpl; //导入依赖的package包/类
@Override
public List<Site> readAllActiveSites() {
    CriteriaBuilder builder = em.getCriteriaBuilder();
    CriteriaQuery<Site> criteria = builder.createQuery(Site.class);
    Root<SiteImpl> site = criteria.from(SiteImpl.class);
    criteria.select(site);
    criteria.where(
        builder.and(
            builder.or(builder.isNull(site.get("archiveStatus").get("archived").as(String.class)),
                builder.notEqual(site.get("archiveStatus").get("archived").as(Character.class), 'Y')),
            builder.or(builder.isNull(site.get("deactivated").as(Boolean.class)),
                builder.notEqual(site.get("deactivated").as(Boolean.class), true))
        )
    );
    
    TypedQuery<Site> query = em.createQuery(criteria);
    query.setHint(QueryHints.HINT_CACHEABLE, true);
    
    return query.getResultList();
}
 
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:21,代码来源:SiteDaoImpl.java

示例2: testBuildFileName

import org.broadleafcommerce.common.site.domain.SiteImpl; //导入依赖的package包/类
/**
 * For example, if the URL is /product/myproductimage.jpg, then the MD5 would be
 * 35ec52a8dbd8cf3e2c650495001fe55f resulting in the following file on the filesystem
 * {assetFileSystemPath}/64/a7/myproductimage.jpg.
 * 
 * If there is a "siteId" in the BroadleafRequestContext then the site is also distributed
 * using a similar algorithm but the system attempts to keep images for sites in their own
 * directory resulting in an extra two folders required to reach any given product.   So, for
 * site with id 125, the system will MD5 "site125" in order to build the URL string.   "site125" has an md5
 * string of "7d905e85b8cb72a0477632be2c342bd6".    
 * 
 * So, in this case with the above product URL in site125, the full URL on the filesystem
 * will be:
 * 
 * {assetFileSystemPath}/7d/site125/64/a7/myproductimage.jpg.
 * @throws Exception
 */
public void testBuildFileName() throws Exception {
    FileSystemFileServiceProvider provider = new FileSystemFileServiceProvider();
    String tmpdir = FileUtils.getTempDirectoryPath();
    if (!tmpdir.endsWith(File.separator)) {
        tmpdir = tmpdir + File.separator;
    }
    provider.fileSystemBaseDirectory = FilenameUtils.concat(tmpdir, "test");
    provider.maxGeneratedDirectoryDepth = 2;
    File file = provider.getResource("/product/myproductimage.jpg");
    
    String resultPath = tmpdir + StringUtils.join(new String[] {"test", "35", "ec", "myproductimage.jpg"}, File.separator);
    assertEquals(file.getAbsolutePath(), FilenameUtils.normalize(resultPath));

    BroadleafRequestContext brc = new BroadleafRequestContext();
    BroadleafRequestContext.setBroadleafRequestContext(brc);

    Site site = new SiteImpl();
    site.setId(125L);
    brc.setSite(site);

    // try with site specific directory
    file = provider.getResource("/product/myproductimage.jpg");
    resultPath = tmpdir + StringUtils.join(new String[] {"test", "c8", "site-125", "35", "ec", "myproductimage.jpg"}, File.separator);
    assertEquals(file.getAbsolutePath(), resultPath);

    // try with 3 max generated directories
    provider.maxGeneratedDirectoryDepth = 3;
    file = provider.getResource("/product/myproductimage.jpg");
    resultPath = tmpdir + StringUtils.join(new String[] {"test", "c8", "site-125", "35", "ec", "52", "myproductimage.jpg"}, File.separator);
    assertEquals(file.getAbsolutePath(), resultPath);
    
    // Remove the request context from thread local so it doesn't get in the way of subsequent tests
    BroadleafRequestContext.setBroadleafRequestContext(null);
}
 
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:52,代码来源:FileSystemFileServiceProviderTest.java

示例3: testSiteMapsWithSiteContext

import org.broadleafcommerce.common.site.domain.SiteImpl; //导入依赖的package包/类
@Test
public void testSiteMapsWithSiteContext() throws SiteMapException, IOException {
    BroadleafRequestContext brc = new BroadleafRequestContext();
    BroadleafRequestContext.setBroadleafRequestContext(brc);

    Site site = new SiteImpl();
    site.setId(256L);
    brc.setSite(site);
    
    CustomUrlSiteMapGeneratorConfiguration smgc = getConfiguration();
    testGenerator(smgc, new CustomUrlSiteMapGenerator());

    File file1 = fileService.getResource("/sitemap_index.xml");
    File file2 = fileService.getResource("/sitemap1.xml");
    File file3 = fileService.getResource("/sitemap2.xml");
    
    assertThat(file1.getAbsolutePath(), containsString("site-256"));
    assertThat(file2.getAbsolutePath(), containsString("site-256"));
    assertThat(file3.getAbsolutePath(), containsString("site-256"));

    compareFiles(file1, "src/test/resources/org/broadleafcommerce/sitemap/custom/sitemap_index.xml");
    compareFiles(file2, "src/test/resources/org/broadleafcommerce/sitemap/custom/sitemap1.xml");
    compareFiles(file3, "src/test/resources/org/broadleafcommerce/sitemap/custom/sitemap2.xml");
    
    // Remove the request context from thread local so it doesn't get in the way of subsequent tests
    BroadleafRequestContext.setBroadleafRequestContext(null);
}
 
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:28,代码来源:CustomUrlSiteMapGeneratorTest.java

示例4: retrieve

import org.broadleafcommerce.common.site.domain.SiteImpl; //导入依赖的package包/类
@Override
public Site retrieve(Long id) {
    return em.find(SiteImpl.class, id);
}
 
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:5,代码来源:SiteDaoImpl.java

示例5: retrieveSiteByDomainOrDomainPrefix

import org.broadleafcommerce.common.site.domain.SiteImpl; //导入依赖的package包/类
@Override
public Site retrieveSiteByDomainOrDomainPrefix(String domain, String domainPrefix) {
    if (domain == null) {
        return null;
    }

    List<String> siteIdentifiers = new ArrayList<String>();
    siteIdentifiers.add(domain);
    siteIdentifiers.add(domainPrefix);

    CriteriaBuilder builder = em.getCriteriaBuilder();
    CriteriaQuery<Site> criteria = builder.createQuery(Site.class);
    Root<SiteImpl> site = criteria.from(SiteImpl.class);
    criteria.select(site);

    criteria.where(builder.and(site.get("siteIdentifierValue").as(String.class).in(siteIdentifiers),
            builder.and(
                builder.or(builder.isNull(site.get("archiveStatus").get("archived").as(String.class)),
                    builder.notEqual(site.get("archiveStatus").get("archived").as(Character.class), 'Y')),
                builder.or(builder.isNull(site.get("deactivated").as(Boolean.class)),
                    builder.notEqual(site.get("deactivated").as(Boolean.class), true))
            )
        )
    );
    TypedQuery<Site> query = em.createQuery(criteria);
    query.setHint(QueryHints.HINT_CACHEABLE, true);

    List<Site> results = query.getResultList();
    
    for (Site currentSite : results) {
        if (SiteResolutionType.DOMAIN.equals(currentSite.getSiteResolutionType())) {
            if (domain.equals(currentSite.getSiteIdentifierValue())) {
                return currentSite;
            }
        }

        if (SiteResolutionType.DOMAIN_PREFIX.equals(currentSite.getSiteResolutionType())) {
            if (domainPrefix.equals(currentSite.getSiteIdentifierValue())) {
                return currentSite;
            }
        }
        
        // We need to forcefully load this collection.
        currentSite.getCatalogs().size();
    }

    return null;
}
 
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:49,代码来源:SiteDaoImpl.java

示例6: createLightWeightCloneFromJson

import org.broadleafcommerce.common.site.domain.SiteImpl; //导入依赖的package包/类
/**
 * Resurrect the BroadleafRequestContext state based on a JSON representation.
 *
 * @param Json
 * @param em
 * @return
 */
public static BroadleafRequestContext createLightWeightCloneFromJson(String Json, EntityManager em) {
    BroadleafRequestContext context = new BroadleafRequestContext();
    JsonFactory factory = new JsonFactory();
    ObjectMapper mapper = new ObjectMapper(factory);
    TypeReference<HashMap<String,String>> typeRef = new TypeReference<HashMap<String,String>>() {};
    HashMap<String,String> json;
    try {
        json = mapper.readValue(Json, typeRef);
    } catch (IOException e) {
        throw ExceptionHelper.refineException(e);
    }
    if (!json.get("ignoreSite").equals("null")) {
        context.setIgnoreSite(Boolean.valueOf(json.get("ignoreSite")));
    }
    if (!json.get("sandBox").equals("null")) {
        context.setSandBox(em.find(SandBoxImpl.class, Long.parseLong(json.get("sandBox"))));
    }
    if (!json.get("nonPersistentSite").equals("null")) {
        context.setNonPersistentSite(em.find(SiteImpl.class, Long.parseLong(json.get("nonPersistentSite"))));
    }
    if (!json.get("enforceEnterpriseCollectionBehaviorState").equals("null")) {
        context.setEnforceEnterpriseCollectionBehaviorState(EnforceEnterpriseCollectionBehaviorState.valueOf(json
                .get("enforceEnterpriseCollectionBehaviorState")));
    }
    if (!json.get("admin").equals("null")) {
        context.setAdmin(Boolean.valueOf(json.get("admin")));
    }
    if (!json.get("adminUserId").equals("null")) {
        context.setAdminUserId(Long.parseLong(json.get("ignoreSite")));
    }
    if (!json.get("broadleafCurrency").equals("null")) {
        context.setBroadleafCurrency(em.find(BroadleafCurrencyImpl.class, json.get("broadleafCurrency")));
    }
    if (!json.get("currentCatalog").equals("null")) {
        context.setCurrentCatalog(em.find(CatalogImpl.class, Long.parseLong(json.get("currentCatalog"))));
    }
    if (!json.get("currentProfile").equals("null")) {
        context.setCurrentProfile(em.find(SiteImpl.class, Long.parseLong(json.get("currentProfile"))));
    }
    if (!json.get("deployBehavior").equals("null")) {
        context.setDeployBehavior(DeployBehavior.valueOf(json.get("deployBehavior")));
    }
    if (!json.get("deployState").equals("null")) {
        context.setDeployState(DeployState.valueOf(json.get("deployState")));
    }
    if (!json.get("internalIgnoreFilters").equals("null")) {
        context.setInternalIgnoreFilters(Boolean.valueOf(json.get("internalIgnoreFilters")));
    }
    if (!json.get("locale").equals("null")) {
        context.setLocale(em.find(LocaleImpl.class, json.get("locale")));
    }
    if (!json.get("validateProductionChangesState").equals("null")) {
        context.setValidateProductionChangesState(ValidateProductionChangesState.valueOf(json.get("validateProductionChangesState")));
    }
    if (!json.get("timeZone").equals("null")) {
        context.setTimeZone(TimeZone.getTimeZone(json.get("timeZone")));
    }

    return context;
}
 
开发者ID:takbani,项目名称:blcdemo,代码行数:68,代码来源:BroadleafRequestContext.java

示例7: retrieveSiteByDomainOrDomainPrefix

import org.broadleafcommerce.common.site.domain.SiteImpl; //导入依赖的package包/类
@Override
public Site retrieveSiteByDomainOrDomainPrefix(String domain, String domainPrefix) {
    if (domain == null) {
        return null;
    }

    List<String> siteIdentifiers = new ArrayList<String>();
    siteIdentifiers.add(domain);
    siteIdentifiers.add(domainPrefix);

    CriteriaBuilder builder = em.getCriteriaBuilder();
    CriteriaQuery<Site> criteria = builder.createQuery(Site.class);
    Root<SiteImpl> site = criteria.from(SiteImpl.class);
    criteria.select(site);

    criteria.where(builder.and(site.get("siteIdentifierValue").as(String.class).in(siteIdentifiers),
            builder.and(
                builder.or(builder.isNull(site.get("archiveStatus").get("archived").as(String.class)),
                    builder.notEqual(site.get("archiveStatus").get("archived").as(Character.class), 'Y')),
                builder.or(builder.isNull(site.get("deactivated").as(Boolean.class)),
                    builder.notEqual(site.get("deactivated").as(Boolean.class), true))
            )
        )
    );
    TypedQuery<Site> query = em.createQuery(criteria);
    query.setHint(QueryHints.HINT_CACHEABLE, true);

    List<Site> results = query.getResultList();
    
    for (Site currentSite : results) {
        if (SiteResolutionType.DOMAIN.equals(currentSite.getSiteResolutionType())) {
            if (domain.equals(currentSite.getSiteIdentifierValue())) {
                return currentSite;
            }
        }

        if (SiteResolutionType.DOMAIN_PREFIX.equals(currentSite.getSiteResolutionType())) {
            if (domainPrefix.equals(currentSite.getSiteIdentifierValue())) {
                return currentSite;
            }
        }
    }

    return null;
}
 
开发者ID:takbani,项目名称:blcdemo,代码行数:46,代码来源:SiteDaoImpl.java


注:本文中的org.broadleafcommerce.common.site.domain.SiteImpl类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。