Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2005-2013 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.opensource.org/licenses/ecl2.php Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package org.kuali.rice.kew.impl.repository;
 
 
 import java.util.List;
 import java.util.Map;
 
 
 public final class KewTypeBoServiceImpl implements KewTypeRepositoryService {
 
This overridden method creates a KewType if it does not already exist in the repository.

 
 		if (kewType == null){
 	        throw new RiceIllegalArgumentException("kewType is null");
 		}
 		final String nameKey = kewType.getName();
 		final String namespaceKey = kewType.getNamespace();
 		final KewTypeDefinition existing = getTypeByNameAndNamespace(nameKeynamespaceKey);
 		if (existing != null && existing.getName().equals(nameKey) && existing.getNamespace().equals(namespaceKey)){
             throw new RiceIllegalStateException("The KEW Type to create already exists: " + kewType);
 		}
 		
 		KewTypeBo bo = (KewTypeBo).save(KewTypeBo.from(kewType));
 		
 		return KewTypeBo.to(bo);
 	}

 
 	public void updateKewType(KewTypeDefinition kewType) {
         if (kewType == null) {
             throw new RiceIllegalArgumentException("kewType is null");
         }
 		final String idKey = kewType.getId();
 		final KewTypeBo existing = .findBySinglePrimaryKey(KewTypeBo.classidKey);
         if (existing == null) {
             throw new RiceIllegalStateException("The KEW type does not exist: " + kewType);
         }
         final KewTypeDefinition toUpdate;
         if (!existing.getId().equals(kewType.getId())){
         	final KewTypeDefinition.Builder builder = KewTypeDefinition.Builder.create(kewType);
         	builder.setId(existing.getId());
         	toUpdate = builder.build();
         } else {
         	toUpdate = kewType;
         }
         
         .save(KewTypeBo.from(toUpdate));
 	}
 
     @Override
     public KewTypeDefinition getTypeById(final String id) {
         if (StringUtils.isBlank(id)) {
             throw new RiceIllegalArgumentException("id is blank");
         }
 
         KewTypeBo kewTypeBo = .findBySinglePrimaryKey(KewTypeBo.classid);
 
         return KewTypeBo.to(kewTypeBo);
     }
 
    @Override
    public KewTypeDefinition getTypeByNameAndNamespace(final String namefinal String namespace) {
        if (StringUtils.isBlank(name)) {
            throw new RiceIllegalArgumentException("name is blank");
        }
        if (StringUtils.isBlank(namespace)) {
            throw new RiceIllegalArgumentException("namespace is blank");
        }
        final Map<StringObjectmap = new HashMap<StringObject>();
        map.put("name"name);
        map.put("namespace"namespace);
        KewTypeBo myType = .findByPrimaryKey(KewTypeBo.class, Collections.unmodifiableMap(map));
        return KewTypeBo.to(myType);
    }
    @Override
    public List<KewTypeDefinitionfindAllTypesByNamespace(final String namespace) {
        if (StringUtils.isBlank(namespace)) {
            throw new RiceIllegalArgumentException("namespace is blank");
        }
        final Map<StringObjectmap = new HashMap<StringObject>();
        map.put("namespace"namespace);
        map.put("active".);
        Collection<KewTypeBokewTypeBos = .findMatching(KewTypeBo.class, Collections.unmodifiableMap(map));
        return convertListOfBosToImmutables(kewTypeBos);
    }
    @Override
    public List<KewTypeDefinitionfindAllTypes() {
        final Map<StringObjectmap = new HashMap<StringObject>();
        map.put("active".);
        Collection<KewTypeBokewTypeBos = .findMatching(KewTypeBo.class, Collections.unmodifiableMap(map));
        return convertListOfBosToImmutables(kewTypeBos);
    }

    
Sets the businessObjectService attribute value.

Parameters:
businessObjectService The businessObjectService to set.
    public void setBusinessObjectService(final BusinessObjectService businessObjectService) {
        this. = businessObjectService;
    }

    
Converts a List<KewTypeBo> to an Unmodifiable List<KewType>

Parameters:
kewTypeBos a mutable List<KewTypeBo> to made completely immutable.
Returns:
An unmodifiable List<KewType>
        ArrayList<KewTypeDefinitionkewTypes = new ArrayList<KewTypeDefinition>();
        for (KewTypeBo bo : kewTypeBos) {
            KewTypeDefinition kewType = KewTypeBo.to(bo);
            kewTypes.add(kewType);
        }
        return Collections.unmodifiableList(kewTypes);
    }

This overridden method creates a KewTypeAttribute if it does not already exist in the repository.

	public void createKewTypeAttribute(KewTypeAttribute kewTypeAttribute) {
        if (kewTypeAttribute == null){
            throw new RiceIllegalArgumentException("kewTypeAttribute is null");
        }
        
        final String typeIdKey = kewTypeAttribute.getTypeId();
        final String attrDefIdKey = kewTypeAttribute.getAttributeDefinitionId();
        
        final Map<StringObjectmap = new HashMap<StringObject>();
        map.put("typeId"typeIdKey);
        map.put("attributeDefinitionId"attrDefIdKey);
        KewTypeAttributeBo existing = .findByPrimaryKey(KewTypeAttributeBo.class, Collections.unmodifiableMap(map));
        if (existing != null && existing.getTypeId().equals(typeIdKey) && existing.getAttributeDefinitionId().equals(attrDefIdKey)){
            throw new RiceIllegalStateException("The KEW Type Attribute to create already exists: " + kewTypeAttribute);
        }
        
        KewTypeAttributeBo bo = (KewTypeAttributeBo).save(KewTypeAttributeBo.from(kewTypeAttribute));
    }

    
    @Override
    public void updateKewTypeAttribute(KewTypeAttribute kewTypeAttribute) {
        if (kewTypeAttribute == null) {
            throw new RiceIllegalArgumentException("kewTypeAttribute is null");
        }
        final String idKey = kewTypeAttribute.getId();
        final KewTypeAttributeBo existing = .findBySinglePrimaryKey(KewTypeAttributeBo.classidKey);
        if (existing == null) {
            throw new RiceIllegalStateException("The KEW type Attribute does not exist: " + kewTypeAttribute);
        }
        final KewTypeAttribute toUpdate;
        if (!existing.getId().equals(kewTypeAttribute.getId())){
            final KewTypeAttribute.Builder builder = KewTypeAttribute.Builder.create(kewTypeAttribute);
            builder.setId(existing.getId());
            toUpdate = builder.build();
        } else {
            toUpdate = kewTypeAttribute;
        }
        
        .save(KewTypeAttributeBo.from(toUpdate));
    }
New to GrepCode? Check out our FAQ X