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.ken.service.impl;
 
 
 import java.util.Map;
 
 //import org.apache.ojb.broker.query.QueryByCriteria;
 //import org.apache.ojb.broker.query.QueryFactory;
 //import org.kuali.rice.core.jpa.criteria.Criteria;
 

NotificationContentTypeService implementation - uses the businessObjectDao to get at the underlying data in the stock DBMS.

Author(s):
Kuali Rice Team (rice.collab@kuali.org)
 
     private GenericDao businessObjectDao;

    
Constructs a NotificationContentTypeServiceImpl.java.

Parameters:
businessObjectDao
 
     public NotificationContentTypeServiceImpl(GenericDao businessObjectDao) {
         this. = businessObjectDao;
     }

    
 
     //this is the one need to tweek on criteria
 //        Criteria c = new Criteria();
 //        c.addEqualTo("name", name);
 //        c.addEqualTo("current", true);	
 //    	Criteria c = new Criteria(NotificationContentType.class.getName());
 //    	c.eq("name", name);
 //    	c.eq("current", true);
     	Map<StringObjectc = new HashMap<StringObject>();
     	c.put("name"name);
     	c.put("current"new Boolean(true));
     	
         if (coll.size() == 0) {
             return null;
         } else {
             return coll.iterator().next();
         }
     }
 
     protected int findHighestContentTypeVersion(String name) {
         // there's probably a better way...'report'? or direct SQL
         Map<StringObjectfields = new HashMap<StringObject>(2);
         fields.put("name"name);
         Collection<NotificationContentTypeBotypes = .findMatchingOrderBy(NotificationContentTypeBo.classfields"version"false);
         if (types.size() > 0) {
             return types.iterator().next().getVersion();
         }
         return -1;
     }

    
 
     public void saveNotificationContentType(NotificationContentTypeBo contentType) {
         NotificationContentTypeBo previous = getNotificationContentType(contentType.getName());
         if (previous != null) {
             previous.setCurrent(false);
             .save(previous);
         }
         int lastVersion = findHighestContentTypeVersion(contentType.getName());
         NotificationContentTypeBo next;
         if (contentType.getId() == null) {
             next = contentType
         } else {
             next = new NotificationContentTypeBo();
             next.setName(contentType.getName());
             next.setDescription(contentType.getDescription());
             next.setNamespace(contentType.getNamespace());
             next.setXsd(contentType.getXsd());
            next.setXsl(contentType.getXsl());
        }
        next.setVersion(lastVersion + 1);
        next.setCurrent(true);
        .save(next);
        
        // update all the old references
        if (previous != null) {
            Collection<NotificationBons = getNotificationsOfContentType(previous);
            for (NotificationBo nns) {
                n.setContentType(next);
                .save(n);
            }
        }
    }
        Map<StringObjectfields = new HashMap<StringObject>(1);
        fields.put("contentType"ct.getId());
        return .findMatching(NotificationBo.classfields);
    }
    
//        Criteria c = new Criteria();
//        c.addEqualTo("current", true);
////    	Criteria c = new Criteria(NotificationContentType.class.getName());
////    	c.eq("current", true);
    	
    	Map<StringBooleanc = new HashMap<StringBoolean>();
    	c.put("current"new Boolean(true));
   
        return .findMatching(NotificationContentTypeBo.classc);
    }
    
    
    }
New to GrepCode? Check out our FAQ X