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


Java RatingScheme类代码示例

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


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

示例1: init

import org.alfresco.service.cmr.rating.RatingScheme; //导入依赖的package包/类
/**
 * Initialise method
 */
public void init()
{
    // Prevent the ratebale aspect from being copied
    bindNoCopyBehaviour(ContentModel.ASPECT_RATEABLE);

    // Prevent the roll up aspects from being copied
    for (RatingScheme ratingScheme : ratingSchemeRegistry.getRatingSchemes().values())
    {
        if (ratingScheme.getPropertyRollups() != null && ratingScheme.getPropertyRollups().size() > 0) 
        {
            QName rollupAspectName = ratingNamingConventions.getRollupAspectNameFor(ratingScheme);
            bindNoCopyBehaviour(rollupAspectName);
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:19,代码来源:RateableAspect.java

示例2: getRatingRollup

import org.alfresco.service.cmr.rating.RatingScheme; //导入依赖的package包/类
@Extend(traitAPI=RatingServiceTrait.class,extensionAPI=RatingServiceExtension.class)
public Serializable getRatingRollup(NodeRef targetNode, String ratingSchemeName, String ratingRollupName)
{
    RatingScheme scheme = schemeRegistry.getRatingSchemes().get(ratingSchemeName);
    if (scheme == null)
    {
        throw new RatingServiceException("Cannot retrieve rollup. Unrecognized rating scheme " + ratingSchemeName);
    }
    
    QName rollupAspectName = ratingNamingConventions.getRollupAspectNameFor(scheme);

    Serializable result = null;
    // If the rated node has the rollup aspect applied
    if (nodeService.hasAspect(targetNode, rollupAspectName))
    {
        QName rollupPropertyName = ratingNamingConventions.getRollupPropertyNameFor(scheme, ratingRollupName);
        result = nodeService.getProperty(targetNode, rollupPropertyName);
    }
    
    return result;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:22,代码来源:RatingServiceImpl.java

示例3: getRatingFrom

import org.alfresco.service.cmr.rating.RatingScheme; //导入依赖的package包/类
/**
 * This method returns a {@link Rating} object for the specified cm:rating node.
 * @param ratingNode NodeRef
 * @return Rating
 */
Rating getRatingFrom(NodeRef ratingNode)
{
    // The appliedBy is encoded in the parent assoc qname.
    // It will be the same user for all ratings in this node.
    ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(ratingNode);
    String appliedBy = parentAssoc.getQName().getLocalName();
    
    Map<QName, Serializable> properties = nodeService.getProperties(ratingNode);
    
    final String schemeName = (String)properties.get(ContentModel.PROP_RATING_SCHEME);
    final Float score = (Float)properties.get(ContentModel.PROP_RATING_SCORE);
    final Date ratedAt = (Date)properties.get(ContentModel.PROP_RATED_AT);
    RatingScheme scheme = getRatingScheme(schemeName);
    Rating result = new Rating(scheme, score, appliedBy, ratedAt);
    return result;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:22,代码来源:RatingServiceImpl.java

示例4: outOfTheBoxRatingSchemes

import org.alfresco.service.cmr.rating.RatingScheme; //导入依赖的package包/类
/**
 * This method tests that the expected 'out of the box' rating schemes are available
 * and correctly initialised.
 */
@Test public void outOfTheBoxRatingSchemes() throws Exception
{
    Map<String, RatingScheme> schemes = RATING_SERVICE.getRatingSchemes();
    
    assertNotNull("rating scheme collection was null.", schemes);
    assertTrue("rating scheme collection was empty.", schemes.isEmpty() == false);
    
    RatingScheme likesRS = schemes.get(LIKES_SCHEME_NAME);
    assertNotNull("'likes' rating scheme was missing.", likesRS);
    assertEquals("'likes' rating scheme had wrong name.", LIKES_SCHEME_NAME, likesRS.getName());
    assertEquals("'likes' rating scheme had wrong min.", 1, (int)likesRS.getMinRating());
    assertEquals("'likes' rating scheme had wrong max.", 1, (int)likesRS.getMaxRating());
    
    RatingScheme fiveStarRS = schemes.get(FIVE_STAR_SCHEME_NAME);
    assertNotNull("'5*' rating scheme was missing.", fiveStarRS);
    assertEquals("'5*' rating scheme had wrong name.", FIVE_STAR_SCHEME_NAME, fiveStarRS.getName());
    assertEquals("'5*' rating scheme had wrong min.", 1, (int)fiveStarRS.getMinRating());
    assertEquals("'5*' rating scheme had wrong max.", 5, (int)fiveStarRS.getMaxRating());
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:24,代码来源:RatingServiceIntegrationTest.java

示例5: register

import org.alfresco.service.cmr.rating.RatingScheme; //导入依赖的package包/类
public void register(String name, RatingScheme ratingScheme)
{
    ratingSchemes.put(name, ratingScheme);
    if (log.isDebugEnabled())
    {
        StringBuilder msg = new StringBuilder();
        msg.append("Registering ")
           .append(ratingScheme);

        log.debug(msg.toString());
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:13,代码来源:RatingSchemeRegistry.java

示例6: getRollupAspectNameFor

import org.alfresco.service.cmr.rating.RatingScheme; //导入依赖的package包/类
/**
 * Given a ratingScheme, this method returns the aspect name which would
 * by convention be used to store rating property rollups.
 * 
 * @param ratingScheme the ratingScheme.
 * @return the aspect name used to store all property rollups for that scheme.
 */
public QName getRollupAspectNameFor(RatingScheme ratingScheme)
{
    final String modelPrefix = ratingScheme.getModelPrefix();
    final String ratingSchemeName = ratingScheme.getName();
    
    String result = modelPrefix + ":" + ratingSchemeName + "Rollups";
    return QName.createQName(result, namespaceService);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:16,代码来源:RatingNamingConventionsUtil.java

示例7: getRollupPropertyNameFor

import org.alfresco.service.cmr.rating.RatingScheme; //导入依赖的package包/类
/**
 * Given a ratingScheme and a rollup name, this method returns the property name
 * which would by convention be used to store the given rollup.
 * 
 * @param ratingScheme the ratingScheme.
 * @param rollupName the name of the property rollup as given by {@link AbstractRatingRollupAlgorithm#getRollupName()}.
 * @return the property name used to persist the given rollup in the given scheme.
 */
public QName getRollupPropertyNameFor(RatingScheme ratingScheme, String rollupName)
{
    final String modelPrefix = ratingScheme.getModelPrefix();
    final String ratingSchemeName = ratingScheme.getName();
    
    String result = modelPrefix + ":" + ratingSchemeName + rollupName;
    return QName.createQName(result, namespaceService);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:17,代码来源:RatingNamingConventionsUtil.java

示例8: itIsPossibleToDefineCustomRatingSchemes

import org.alfresco.service.cmr.rating.RatingScheme; //导入依赖的package包/类
/** ALF-17861 */
@Test public void itIsPossibleToDefineCustomRatingSchemes() throws Exception
{
    // This is obviously only visible in test code.
    final String spinalTapScheme = "spinalTapRatingScheme";
    final QName rollupAspect = QName.createQName("http://www.alfresco.org/model/testratings/1.0", "spinalTapRatingSchemeRollups");
    final QName countProp = QName.createQName("http://www.alfresco.org/model/testratings/1.0", "spinalTapRatingSchemeCount");
    final QName totalProp = QName.createQName("http://www.alfresco.org/model/testratings/1.0", "spinalTapRatingSchemeTotal");
    
    RatingScheme spinalTap = RATING_SERVICE.getRatingScheme(spinalTapScheme);
    assertEquals(11.0f, spinalTap.getMaxRating(), 0.0001f);
    
    
    // So the rating scheme exists. Now to use it.
    // Apply a rating.
    TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback<NodeRef>()
    {
        @Override public NodeRef execute() throws Throwable
        {
            RATING_SERVICE.applyRating(testDoc_UserOne, 11.0F, spinalTapScheme);
            return null;
        }
    });
    
    // Now we'll go back to the node and check that the rollups were calculated.
    TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback<NodeRef>()
    {
        @Override public NodeRef execute() throws Throwable
        {
            assertTrue(NODE_SERVICE.hasAspect(testDoc_UserOne, rollupAspect));
            final int count = (Integer)NODE_SERVICE.getProperty(testDoc_UserOne, countProp);
            final float total = (Float)NODE_SERVICE.getProperty(testDoc_UserOne, totalProp);
            
            assertEquals(1, count);
            assertEquals("But this one goes to 11. See? 11.", 11, total, 0.1);
            return null;
        }
    });
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:40,代码来源:RatingServiceIntegrationTest.java

示例9: executeImpl

import org.alfresco.service.cmr.rating.RatingScheme; //导入依赖的package包/类
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
    Map<String, Object> model = new HashMap<String, Object>();

    Map<String, RatingScheme> schemes = this.ratingService.getRatingSchemes();
    
    model.put("schemeDefs", schemes);

    return model;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:12,代码来源:RatingDefinitionsGet.java

示例10: getRatingSchemes

import org.alfresco.service.cmr.rating.RatingScheme; //导入依赖的package包/类
@Extend(traitAPI=RatingServiceTrait.class,extensionAPI=RatingServiceExtension.class)
public Map<String, RatingScheme> getRatingSchemes()
{
    // This is already an unmodifiable Map.
    return schemeRegistry.getRatingSchemes();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:7,代码来源:RatingServiceImpl.java

示例11: getRatingScheme

import org.alfresco.service.cmr.rating.RatingScheme; //导入依赖的package包/类
@Extend(traitAPI=RatingServiceTrait.class,extensionAPI=RatingServiceExtension.class)
public RatingScheme getRatingScheme(String ratingSchemeName)
{
    return schemeRegistry.getRatingSchemes().get(ratingSchemeName);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:6,代码来源:RatingServiceImpl.java

示例12: getRatingSchemes

import org.alfresco.service.cmr.rating.RatingScheme; //导入依赖的package包/类
/**
 * This method returns an unmodifiable map of the registered rating schemes.
 * @return Map
 */
public Map<String, RatingScheme> getRatingSchemes()
{
    return Collections.unmodifiableMap(ratingSchemes);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:9,代码来源:RatingSchemeRegistry.java

示例13: getRatingSchemes

import org.alfresco.service.cmr.rating.RatingScheme; //导入依赖的package包/类
@Override
public Map<String, RatingScheme> getRatingSchemes()
{
    return getTrait().getRatingSchemes();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:6,代码来源:VirtualRatingServiceExtension.java

示例14: getRatingScheme

import org.alfresco.service.cmr.rating.RatingScheme; //导入依赖的package包/类
@Override
public RatingScheme getRatingScheme(String ratingSchemeName)
{
    return getTrait().getRatingScheme(ratingSchemeName);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:6,代码来源:VirtualRatingServiceExtension.java

示例15: executeImpl

import org.alfresco.service.cmr.rating.RatingScheme; //导入依赖的package包/类
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
    Map<String, Object> model = new HashMap<String, Object>();

    NodeRef nodeRefToBeRated = parseRequestForNodeRef(req);

    JSONObject json = null;
    try
    {
        // read request json
        json = new JSONObject(new JSONTokener(req.getContent().getContent()));
        
        // Check mandatory parameters.
        if (json.has(RATING) == false)
        {
            throw new WebScriptException(Status.STATUS_BAD_REQUEST, "rating parameter missing when applying rating");
        }
        if (json.has(RATING_SCHEME) == false)
        {
            throw new WebScriptException(Status.STATUS_BAD_REQUEST, "schemeName parameter missing when applying rating");
        }
        
        // Check that the scheme name actually exists
        final String schemeName = json.getString(RATING_SCHEME);
        RatingScheme scheme = ratingService.getRatingScheme(schemeName);
        if (scheme == null)
        {
            throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Unknown scheme name: " + schemeName);
        }
        
        // Range checking of the rating score will be done within the RatingService.
        // So we can just apply the rating.
        final float rating = (float)json.getDouble(RATING);
        ratingService.applyRating(nodeRefToBeRated, rating, schemeName);

        // We'll return the URL to the ratings of the just-rated node.
        String ratedNodeUrlFragment = nodeRefToBeRated.toString().replace("://", "/");
        String ratedNodeUrl = MessageFormat.format(NODE_RATINGS_URL_FORMAT, ratedNodeUrlFragment);

        model.put(RATED_NODE, ratedNodeUrl);
        model.put(RATING, rating);
        model.put(RATING_SCHEME, schemeName);
        model.put(AVERAGE_RATING, ratingService.getAverageRating(nodeRefToBeRated, schemeName));
        model.put(RATINGS_TOTAL, ratingService.getTotalRating(nodeRefToBeRated, schemeName));
        model.put(RATINGS_COUNT, ratingService.getRatingsCount(nodeRefToBeRated, schemeName));
    }
    catch (IOException iox)
    {
        throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not read content from req.", iox);
    }
    catch (JSONException je)
    {
        throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not parse JSON from req.", je);
    }

    return model;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:59,代码来源:RatingPost.java


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