本文整理汇总了Java中org.kuali.rice.krms.impl.repository.TermSpecificationBo类的典型用法代码示例。如果您正苦于以下问题:Java TermSpecificationBo类的具体用法?Java TermSpecificationBo怎么用?Java TermSpecificationBo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TermSpecificationBo类属于org.kuali.rice.krms.impl.repository包,在下文中一共展示了TermSpecificationBo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateNameNamespace
import org.kuali.rice.krms.impl.repository.TermSpecificationBo; //导入依赖的package包/类
/**
* Check if the name-namespace pair already exist.
* @param termSpec
* @return true if the name-namespace pair is unique, false otherwise
*/
private boolean validateNameNamespace(TermSpecificationBo termSpec) {
if (StringUtils.isNotBlank(termSpec.getName()) && StringUtils.isNotBlank(
termSpec.getNamespace())) {
Map<String, String> criteria = new HashMap<String, String>();
criteria.put("name", termSpec.getName());
criteria.put("namespace", termSpec.getNamespace());
TermSpecificationBo termSpecInDatabase =
findSingleMatching(getDataObjectService(), TermSpecificationBo.class, criteria);
if((termSpecInDatabase != null) && (!StringUtils.equals(termSpecInDatabase.getId(), termSpec.getId()))) {
this.putFieldError(KRMSPropertyConstants.TermSpecification.NAME, "error.term.duplicateNameNamespace");
return false;
}
}
return true;
}
示例2: getTermSpecificationById
import org.kuali.rice.krms.impl.repository.TermSpecificationBo; //导入依赖的package包/类
/**
* @see org.kuali.rice.krms.impl.repository.TermBoService#getTermSpecificationById(java.lang.String)
*/
@Override
public TermSpecificationDefinition getTermSpecificationById(String id) {
TermSpecificationBo termSpecificationBo =
businessObjectService.findBySinglePrimaryKey(TermSpecificationBo.class, id);
// avoid the expense of loading ContextBos by directly looking at ContextValidTermBo reln
Collection<ContextValidTermBo> contextValidTerms =
businessObjectService.findMatching(ContextValidTermBo.class, Collections.singletonMap("termSpecificationId", id));
// populate TermSpecificationBo.contextIds collection
if (contextValidTerms != null) for (ContextValidTermBo contextValidTerm : contextValidTerms) {
termSpecificationBo.getContextIds().add(contextValidTerm.getContextId());
}
return TermSpecificationDefinition.Builder.create(termSpecificationBo).build();
}
示例3: createTermSpecification
import org.kuali.rice.krms.impl.repository.TermSpecificationBo; //导入依赖的package包/类
/**
* @see org.kuali.rice.krms.impl.repository.TermBoService#createTermSpecification(org.kuali.rice.krms.api.repository.term.TermSpecificationDefinition)
*/
@Override
public TermSpecificationDefinition createTermSpecification(TermSpecificationDefinition termSpec) {
if (!StringUtils.isBlank(termSpec.getId())) {
throw new RiceIllegalArgumentException("for creation, TermSpecification.id must be null");
}
TermSpecificationBo termSpecBo = TermSpecificationBo.from(termSpec);
termSpecBo = businessObjectService.save(termSpecBo);
// save relations to the contexts on the BO
if (!CollectionUtils.isEmpty(termSpec.getContextIds())) for (String contextId : termSpec.getContextIds()) {
ContextValidTermBo contextValidTerm = new ContextValidTermBo();
contextValidTerm.setContextId(contextId);
contextValidTerm.setTermSpecificationId(termSpecBo.getId());
businessObjectService.save(contextValidTerm);
}
return TermSpecificationBo.to(termSpecBo);
}
示例4: findAllTermSpecificationsByContextId
import org.kuali.rice.krms.impl.repository.TermSpecificationBo; //导入依赖的package包/类
@Override
public List<TermSpecificationDefinition> findAllTermSpecificationsByContextId(String contextId){
List<TermSpecificationDefinition> results = null;
if (StringUtils.isBlank(contextId)){
throw new RiceIllegalArgumentException("contextId must not be blank or null");
}
Collection<ContextValidTermBo> contextValidTerms =
businessObjectService.findMatching(ContextValidTermBo.class,
Collections.singletonMap("contextId", contextId));
if (!CollectionUtils.isEmpty(contextValidTerms)) {
results = new ArrayList<TermSpecificationDefinition>(contextValidTerms.size());
for (ContextValidTermBo validTerm : contextValidTerms) {
results.add(TermSpecificationBo.to(validTerm.getTermSpecification()));
}
} else {
results = Collections.emptyList();
}
return results;
}
示例5: validateNameNamespace
import org.kuali.rice.krms.impl.repository.TermSpecificationBo; //导入依赖的package包/类
/**
* Check if the name-namespace pair already exist.
* @param termSpec
* @return true if the name-namespace pair is unique, false otherwise
*/
private boolean validateNameNamespace(TermSpecificationBo termSpec) {
if (StringUtils.isNotBlank(termSpec.getName()) && StringUtils.isNotBlank(
termSpec.getNamespace())) {
Map<String, String> criteria = new HashMap<String, String>();
criteria.put("name", termSpec.getName());
criteria.put("namespace", termSpec.getNamespace());
TermSpecificationBo termSpecInDatabase = getBoService().findByPrimaryKey(TermSpecificationBo.class, criteria);
if((termSpecInDatabase != null) && (!StringUtils.equals(termSpecInDatabase.getId(), termSpec.getId()))) {
this.putFieldError(KRMSPropertyConstants.TermSpecification.NAME, "error.term.duplicateNameNamespace");
return false;
}
}
return true;
}
示例6: retrieveObjectForEditOrCopy
import org.kuali.rice.krms.impl.repository.TermSpecificationBo; //导入依赖的package包/类
@Override
public Object retrieveObjectForEditOrCopy(MaintenanceDocument document, Map<String, String> dataObjectKeys) {
TermSpecificationBo termSpecificationBo = (TermSpecificationBo) super.retrieveObjectForEditOrCopy(document,
dataObjectKeys);
if (!CollectionUtils.isEmpty(termSpecificationBo.getContextIds())) {
for (String contextId : termSpecificationBo.getContextIds()) {
ContextDefinition context =
KrmsRepositoryServiceLocator.getContextBoService().getContextByContextId(contextId);
if (context != null) {
termSpecificationBo.getContexts().add(ContextBo.from(context));
}
}
}
if (KRADConstants.MAINTENANCE_COPY_ACTION.equals(getMaintenanceAction())) {
document.getDocumentHeader().setDocumentDescription("New Term Specification Document");
}
return termSpecificationBo;
}
示例7: saveDataObject
import org.kuali.rice.krms.impl.repository.TermSpecificationBo; //导入依赖的package包/类
@Override
public void saveDataObject() {
TermSpecificationBo termSpec = (TermSpecificationBo) getDataObject();
super.saveDataObject(); // save it, it should get an id assigned
if (termSpec.getId() != null) {
// clear all context valid term mappings
getBoService().deleteMatching(ContextValidTermBo.class,
Collections.singletonMap("termSpecificationId", termSpec.getId()));
// add a new mapping for each context in the collection
for (String contextId : termSpec.getContextIds()) {
ContextValidTermBo contextValidTerm = new ContextValidTermBo();
contextValidTerm.setContextId(contextId);
contextValidTerm.setTermSpecificationId(termSpec.getId());
getBoService().save(contextValidTerm);
}
}
}
示例8: processCustomSaveDocumentBusinessRules
import org.kuali.rice.krms.impl.repository.TermSpecificationBo; //导入依赖的package包/类
@Override
protected boolean processCustomSaveDocumentBusinessRules(MaintenanceDocument document) {
boolean isValid = true;
TermSpecificationBo termSpec = (TermSpecificationBo) document.getNewMaintainableObject().getDataObject();
isValid &= validateId(termSpec);
isValid &= validateCategory(termSpec);
isValid &= validateContext(termSpec);
isValid &= validateNameNamespace(termSpec);
return isValid;
}
示例9: validateCategory
import org.kuali.rice.krms.impl.repository.TermSpecificationBo; //导入依赖的package包/类
private boolean validateCategory(TermSpecificationBo termSpecificationBo) {
List<CategoryBo> categories = termSpecificationBo.getCategories();
List<String> categoryIds = new ArrayList<String>();
boolean valid = true;
for (CategoryBo category: categories) {
if (categoryIds.contains(category.getId())) {
this.putFieldError(KRMSPropertyConstants.TermSpecification.CATEGORY, "error.termSpecification.duplicateCategory");
valid = false;
} else {
categoryIds.add(category.getId());
}
}
return valid;
}
示例10: validateContext
import org.kuali.rice.krms.impl.repository.TermSpecificationBo; //导入依赖的package包/类
private boolean validateContext(TermSpecificationBo termSpec) {
List<ContextBo> termSpecContexts = termSpec.getContexts();
List<String> contextIds = new ArrayList<String>();
boolean valid = true;
for (ContextBo context: termSpecContexts) {
if (contextIds.contains(context.getId())) {
this.putFieldError(KRMSPropertyConstants.TermSpecification.CONTEXT, "error.termSpecification.duplicateContext");
valid = false;
} else {
contextIds.add(context.getId());
}
}
return valid;
}
示例11: validateId
import org.kuali.rice.krms.impl.repository.TermSpecificationBo; //导入依赖的package包/类
private boolean validateId(TermSpecificationBo termSpec) {
if (StringUtils.isNotBlank(termSpec.getId())) {
TermSpecificationDefinition termSpecInDatabase = getTermBoService().getTermSpecificationById(termSpec.getId());
if ((termSpecInDatabase != null) && (!StringUtils.equals(termSpecInDatabase.getId(), termSpec.getId()))) {
this.putFieldError(KRMSPropertyConstants.TermSpecification.TERM_SPECIFICATION_ID, "error.termSpecification.duplicateId");
return false;
}
}
return true;
}
示例12: retrieveObjectForEditOrCopy
import org.kuali.rice.krms.impl.repository.TermSpecificationBo; //导入依赖的package包/类
@Override
public Object retrieveObjectForEditOrCopy(MaintenanceDocument document, Map<String, String> dataObjectKeys) {
TermSpecificationBo termSpecificationBo = (TermSpecificationBo) super.retrieveObjectForEditOrCopy(document,
dataObjectKeys);
if (KRADConstants.MAINTENANCE_COPY_ACTION.equals(getMaintenanceAction())) {
document.getDocumentHeader().setDocumentDescription("New Term Specification Document");
}
return termSpecificationBo;
}
示例13: setNewContextValidTermsNewBO
import org.kuali.rice.krms.impl.repository.TermSpecificationBo; //导入依赖的package包/类
private void setNewContextValidTermsNewBO(MaintenanceDocument document) {
TermSpecificationBo newTermSpec = (TermSpecificationBo) document.getNewMaintainableObject().getDataObject();
for (ContextValidTermBo contextValidTermBo : newTermSpec.getContextValidTerms()) {
contextValidTermBo.setId(null);
contextValidTermBo.setTermSpecification(newTermSpec);
}
}
示例14: prepareForSave
import org.kuali.rice.krms.impl.repository.TermSpecificationBo; //导入依赖的package包/类
/**
* Overrides the parent method to additionaly clear the contexts list, which is needed for serialization performance
* & space.
*
* @see org.kuali.rice.krad.maintenance.Maintainable#prepareForSave
*/
@Override
public void prepareForSave() {
super.prepareForSave();
TermSpecificationBo termSpec = (TermSpecificationBo) getDataObject();
termSpec.getContexts().clear();
}
示例15: processCollectionDeleteLine
import org.kuali.rice.krms.impl.repository.TermSpecificationBo; //导入依赖的package包/类
/**
* For context removal, removes the given item from the persisted contextValidTerms collection on the data object.
*
* <p>Without this step, the context is only removed from a transient collection and the severed relationship will
* never be persisted. </p>
*/
@Override
public void processCollectionDeleteLine(ViewModel viewModel, String collectionId, String collectionPath,
int lineIndex) {
List collection = ObjectPropertyUtils.getPropertyValue(viewModel, collectionPath);
Object deletedItem = collection.get(lineIndex);
// we only want to do our custom processing if a context has been deleted
if (deletedItem == null || !(deletedItem instanceof ContextBo)) {
super.processCollectionDeleteLine(viewModel, collectionId, collectionPath, lineIndex);
return;
}
ContextBo context = (ContextBo) deletedItem;
TermSpecificationBo termSpec = getDataObjectFromForm(viewModel);
// find the context and remove it using the special powers of ListIterator
ListIterator<ContextValidTermBo> contextValidTermListIter = termSpec.getContextValidTerms().listIterator();
while (contextValidTermListIter.hasNext()) {
ContextValidTermBo contextValidTerm = contextValidTermListIter.next();
if (contextValidTerm.getContextId().equals(context.getId())) {
contextValidTerm.setTermSpecification(null);
contextValidTermListIter.remove();
termSpec.getContexts().remove(context);
}
}
}