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


Java RecipientPreference类代码示例

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


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

示例1: getRecipientPreference

import org.kuali.rice.kcb.bo.RecipientPreference; //导入依赖的package包/类
/**
 * @see org.kuali.rice.kcb.service.RecipientPreferenceService#getRecipientPreference(java.lang.String, java.lang.String)
 */
public RecipientPreference getRecipientPreference(String recipientId, String key) {
    QueryByCriteria.Builder criteria = QueryByCriteria.Builder.create();
    criteria.setPredicates(
            equal(RecipientPreference.RECIPIENT_FIELD, recipientId),
            equal(RecipientPreference.PROPERTY_FIELD, key)
    );
    List<RecipientPreference> prefs = dataObjectService.findMatching(RecipientPreference.class, criteria.build()).getResults();
    assert(prefs.size() <= 1);

    if (prefs.isEmpty()) {
        return null;
    } else {
        return prefs.get(0);
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:19,代码来源:RecipientPreferenceServiceImpl.java

示例2: saveRecipientPreferences

import org.kuali.rice.kcb.bo.RecipientPreference; //导入依赖的package包/类
/**
 * @see org.kuali.rice.kcb.service.RecipientPreferenceService#saveRecipientPreferences(java.lang.String, java.util.HashMap, org.kuali.rice.kcb.deliverer.MessageDeliverer)
 */
public void saveRecipientPreferences(String recipientId, HashMap<String, String> prefs, MessageDeliverer deliverer) throws ErrorList {
    deliverer.validatePreferenceValues(prefs);         
    
    for (Map.Entry<String, String> entry: prefs.entrySet()) {
       String prop = entry.getKey();
       String value = entry.getValue();
           
       // We need to check if this property is already set
       // for the user by checking doing a unique key query...if
       // it already exists, update, otherwise add it 
       RecipientPreference currentPreference = getRecipientPreference(recipientId, prop);
       if (currentPreference != null) {
          currentPreference.setRecipientId(recipientId);
          currentPreference.setProperty(prop);
          currentPreference.setValue(value);
          dataObjectService.save(currentPreference);
       } else {
          RecipientPreference recipientPreference = new RecipientPreference();
          recipientPreference.setRecipientId(recipientId);
          recipientPreference.setProperty(prop);
          recipientPreference.setValue(value);
          dataObjectService.save(recipientPreference);
       }
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:29,代码来源:RecipientPreferenceServiceImpl.java

示例3: saveRecipientPreferences

import org.kuali.rice.kcb.bo.RecipientPreference; //导入依赖的package包/类
@Test
public void saveRecipientPreferences() throws ErrorList {
    RecipientPreferenceService impl = services.getRecipientPreferenceService();
    MessageDelivererRegistryService delivererService = services.getMessageDelivererRegistryService();
    MessageDeliverer deliverer = delivererService.getDelivererByName(VALID_DELIVERER_NAME);
    if (deliverer == null) {
        throw new RuntimeException("Message deliverer could not be obtained");
    }
        
    HashMap<String, String> userprefs = new HashMap<String, String>();
    userprefs.put(VALID_PROPERTY, VALID_VALUE);
    userprefs.put("Email.email_delivery_format", "text");

    impl.saveRecipientPreferences(VALID_USER_ID, userprefs, deliverer);

    QueryByCriteria.Builder criteria = QueryByCriteria.Builder.create();
    criteria.setPredicates(equal("recipientId", VALID_USER_ID));
    List<RecipientPreference> prefs =
            KRADServiceLocator.getDataObjectService().findMatching(RecipientPreference.class, criteria.build()).getResults();
    assertEquals(2, prefs.size());
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:22,代码来源:RecipientPreferenceServiceTest.java

示例4: testCreate

import org.kuali.rice.kcb.bo.RecipientPreference; //导入依赖的package包/类
@Test
public void testCreate() {
    RecipientPreference p2 = new RecipientPreference();
    p2.setRecipientId("user1");
    p2.setProperty("property2");
    p2.setValue("value2");

    p2 = prefsvc.saveRecipientPreference(p2);
    assertNotNull(p2.getId());

    Map<String, String> p = prefsvc.getRecipientPreferences("user1");
    assertNotNull(p);
    assertEquals(2, p.size());

    assertTrue(p.containsKey("property1"));
    assertTrue(p.containsKey("property2"));
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:18,代码来源:RecipientPreferenceTest.java

示例5: saveRecipientPreferences

import org.kuali.rice.kcb.bo.RecipientPreference; //导入依赖的package包/类
/**
 * @see org.kuali.rice.kcb.service.RecipientPreferenceService#saveRecipientPreferences(java.lang.String, java.util.HashMap, org.kuali.rice.kcb.deliverer.MessageDeliverer)
 */
public void saveRecipientPreferences(String recipientId, HashMap<String, String> prefs, MessageDeliverer deliverer) throws ErrorList {
    deliverer.validatePreferenceValues(prefs);         
    
    for (Map.Entry<String, String> entry: prefs.entrySet()) {
       String prop = entry.getKey();
       String value = entry.getValue();
           
       // We need to check if this property is already set
       // for the user by checking doing a unique key query...if
       // it already exists, update, otherwise add it 
       RecipientPreference currentPreference = getRecipientPreference(recipientId, prop);
       if (currentPreference != null) {
          currentPreference.setRecipientId(recipientId);
          currentPreference.setProperty(prop);
          currentPreference.setValue(value);
          dao.save(currentPreference);
       } else {
          RecipientPreference recipientPreference = new RecipientPreference();
          recipientPreference.setRecipientId(recipientId);
          recipientPreference.setProperty(prop);
          recipientPreference.setValue(value);
          dao.save(recipientPreference);
       }
    }
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:29,代码来源:RecipientPreferenceServiceImpl.java

示例6: testReadByQuery

import org.kuali.rice.kcb.bo.RecipientPreference; //导入依赖的package包/类
/**
 * @see org.kuali.rice.ken.dao.BusinessObjectPersistenceTestCaseBase#retrieve()
 */
@Test
@Override
public void testReadByQuery() {
    testCreate();
    
    HashMap criteria = new HashMap();
    
    criteria.put(RecipientPreference.RECIPIENT_FIELD, recipientIds[0]);
    criteria.put(RecipientPreference.PROPERTY_FIELD, propertys[0]);
    pref1 = (RecipientPreference) businessObjectDao.findByUniqueKey(RecipientPreference.class, criteria);
    
    criteria.clear();
    
    criteria.put(RecipientPreference.RECIPIENT_FIELD, recipientIds[1]);
    criteria.put(RecipientPreference.PROPERTY_FIELD, propertys[1]);
    pref2 = (RecipientPreference) businessObjectDao.findByUniqueKey(RecipientPreference.class, criteria);
    
    assertNotNull(pref1);
    assertEquals(recipientIds[0], pref1.getRecipientId());
    
    assertNotNull(pref2);
    assertEquals(recipientIds[1], pref2.getRecipientId());

}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:28,代码来源:RecipientPreferenceDaoTest.java

示例7: saveRecipientPreferences

import org.kuali.rice.kcb.bo.RecipientPreference; //导入依赖的package包/类
@Test
public void saveRecipientPreferences() throws ErrorList {
    RecipientPreferenceService impl = services.getRecipientPreferenceService();
    MessageDelivererRegistryService delivererService = services.getMessageDelivererRegistryService();
    MessageDeliverer deliverer = delivererService.getDelivererByName(VALID_DELIVERER_NAME);
    if (deliverer == null) {
        throw new RuntimeException("Message deliverer could not be obtained");
    }
        
    HashMap<String, String> userprefs = new HashMap<String, String>();
    userprefs.put(VALID_PROPERTY, VALID_VALUE);
    userprefs.put("Email.email_delivery_format", "text");

    impl.saveRecipientPreferences(VALID_USER_ID, userprefs, deliverer);
    
    RecipientPreference recipientPreference = new RecipientPreference();
    recipientPreference.setRecipientId(VALID_USER_ID);
    Collection<RecipientPreference> prefs = services.getKcbGenericDao().findMatchingByExample(recipientPreference);
    assertEquals(2, prefs.size());
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:21,代码来源:RecipientPreferenceServiceTest.java

示例8: testCreate

import org.kuali.rice.kcb.bo.RecipientPreference; //导入依赖的package包/类
@Test
@Override
public void testCreate() {
    RecipientPreference p2 = new RecipientPreference();
    p2.setRecipientId("user1");
    p2.setProperty("property2");
    p2.setValue("value2");

    prefsvc.saveRecipientPreference(p2);
    assertNotNull(p2.getId());

    Map<String, String> p = prefsvc.getRecipientPreferences("user1");
    assertNotNull(p);
    assertEquals(2, p.size());

    assertTrue(p.containsKey("property1"));
    assertTrue(p.containsKey("property2"));
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:19,代码来源:RecipientPreferenceTest.java

示例9: getRecipientPreferences

import org.kuali.rice.kcb.bo.RecipientPreference; //导入依赖的package包/类
/**
 * @see org.kuali.rice.kcb.service.RecipientPreferenceService#getRecipientPreferences(java.lang.String)
 */
public HashMap<String, String> getRecipientPreferences(String recipientId) {
    QueryByCriteria.Builder criteria = QueryByCriteria.Builder.create();
    criteria.setPredicates(equal(RecipientPreference.RECIPIENT_FIELD, recipientId));
    List<RecipientPreference> userPrefs = dataObjectService.findMatching(RecipientPreference.class, criteria.build()).getResults();

    HashMap<String, String> prefs = new HashMap<String,String>();
    for (RecipientPreference p: userPrefs) {
        prefs.put(p.getProperty(), p.getValue());
    }

    return prefs;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:16,代码来源:RecipientPreferenceServiceImpl.java

示例10: testCreate

import org.kuali.rice.kcb.bo.RecipientPreference; //导入依赖的package包/类
/**
 * Tests creating a {@link RecipientPreference}.
 */
@Test
public void testCreate() {
    RecipientPreference pref1 = createRecipientPreference(0);
    assertNotNull(pref1.getId());

    RecipientPreference pref2 = createRecipientPreference(1);
    assertNotNull(pref2.getId());
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:12,代码来源:RecipientPreferenceDaoTest.java

示例11: testFind

import org.kuali.rice.kcb.bo.RecipientPreference; //导入依赖的package包/类
/**
 * Tests finding a {@link RecipientPreference}.
 */
@Test
public void testFind() {
    RecipientPreference pref1 = createRecipientPreference(0);
    RecipientPreference pref2 = createRecipientPreference(1);

    QueryByCriteria.Builder criteria1 = QueryByCriteria.Builder.create();
    criteria1.setPredicates(equal(RecipientPreference.RECIPIENT_FIELD, recipientIds[0]),
            equal(RecipientPreference.PROPERTY_FIELD, propertys[0]));
    List<RecipientPreference> prefs1 =
            getDataObjectService().findMatching(RecipientPreference.class, criteria1.build()).getResults();

    assertNotNull(pref1);
    assertEquals(prefs1.size(), 1);

    pref1 = prefs1.get(0);
    assertNotNull(pref1);
    assertEquals(recipientIds[0], pref1.getRecipientId());

    QueryByCriteria.Builder criteria2 = QueryByCriteria.Builder.create();
    criteria2.setPredicates(equal(RecipientPreference.RECIPIENT_FIELD, recipientIds[1]),
            equal(RecipientPreference.PROPERTY_FIELD, propertys[1]));
    List<RecipientPreference> prefs2 =
            getDataObjectService().findMatching(RecipientPreference.class, criteria2.build()).getResults();

    assertNotNull(pref2);
    assertEquals(prefs2.size(), 1);
    pref2 = prefs2.get(0);
    assertNotNull(pref2);
    assertEquals(recipientIds[1], pref2.getRecipientId());
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:34,代码来源:RecipientPreferenceDaoTest.java

示例12: testUpdate

import org.kuali.rice.kcb.bo.RecipientPreference; //导入依赖的package包/类
/**
 * Tests updating a {@link RecipientPreference}.
 */
@Test
public void testUpdate() {
    RecipientPreference pref1 = createRecipientPreference(0);
    RecipientPreference pref2 = createRecipientPreference(1);

    pref1.setValue(updatedValues[0]);
    pref2.setValue(updatedValues[1]);

    pref1 = KRADServiceLocator.getDataObjectService().save(pref1, PersistenceOption.FLUSH);
    pref2 = KRADServiceLocator.getDataObjectService().save(pref2, PersistenceOption.FLUSH);
    
    assertEquals(updatedValues[0], pref1.getValue());
    assertEquals(updatedValues[1], pref2.getValue());
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:18,代码来源:RecipientPreferenceDaoTest.java

示例13: testDelete

import org.kuali.rice.kcb.bo.RecipientPreference; //导入依赖的package包/类
/**
 * Tests deleting a {@link RecipientPreference}.
 */
@Test
public void testDelete() {
    RecipientPreference pref1 = createRecipientPreference(0);
    RecipientPreference pref2 = createRecipientPreference(1);

    KRADServiceLocator.getDataObjectService().delete(pref1);
    KRADServiceLocator.getDataObjectService().delete(pref2);

    assertEquals(0, getDataObjectService().findAll(RecipientPreference.class).getResults().size());

}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:15,代码来源:RecipientPreferenceDaoTest.java

示例14: createRecipientPreference

import org.kuali.rice.kcb.bo.RecipientPreference; //导入依赖的package包/类
private RecipientPreference createRecipientPreference(int index) {
    RecipientPreference recipientPreference = new RecipientPreference();
    recipientPreference.setRecipientId(recipientIds[index]);
    recipientPreference.setProperty(propertys[index]);
    recipientPreference.setValue(values[index]);

    return getDataObjectService().save(recipientPreference, PersistenceOption.FLUSH);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:9,代码来源:RecipientPreferenceDaoTest.java

示例15: setUp

import org.kuali.rice.kcb.bo.RecipientPreference; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
    super.setUp();

    prefsvc = GlobalKCBServiceLocator.getInstance().getRecipientPreferenceService();

    PREF = new RecipientPreference();
    PREF.setRecipientId("user1");
    PREF.setProperty("property1");
    PREF.setValue("value1");

    PREF = prefsvc.saveRecipientPreference(PREF);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:14,代码来源:RecipientPreferenceTest.java


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