001/** 002 * Copyright 2005-2016 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.kew.actionitem; 017 018import org.kuali.rice.core.api.delegation.DelegationType; 019 020import javax.persistence.Entity; 021import javax.persistence.NamedQueries; 022import javax.persistence.NamedQuery; 023import javax.persistence.Table; 024import java.util.ArrayList; 025import java.util.Collection; 026import java.util.List; 027import java.util.Map; 028 029/** 030 * This is the model for action items. These are displayed as the action list as well. Mapped to ActionItemService. 031 * NOTE: This object contains denormalized fields that have been copied from related ActionRequestValue and 032 * DocumentRouteHeaderValue 033 * objects for performance reasons. These should be preserved and their related objects should not be added to the OJB 034 * mapping as we do not want them loaded for each ActionItem object. 035 * 036 * @author Kuali Rice Team (rice.collab@kuali.org) 037 */ 038@Entity 039@Table(name = "KREW_ACTN_ITM_T") 040@NamedQueries({@NamedQuery(name = "ActionItem.DistinctDocumentsForPrincipalId", query = 041 "SELECT COUNT(DISTINCT(ai.documentId)) FROM ActionItem ai" 042 + " WHERE ai.principalId = :principalId AND (ai.delegationType IS NULL OR ai.delegationType = 'P')"), 043 @NamedQuery(name = "ActionItem.GetMaxDateAndCountForPrincipalId", query = 044 "SELECT MAX(ai.dateAssigned) AS max_date, COUNT(DISTINCT(ai.documentId)) AS total_records FROM ActionItem ai" 045 + " WHERE ai.principalId = :principalId"), 046 @NamedQuery(name = "ActionItem.GetQuickLinksDocumentTypeNameAndCount", query = 047 "select ai.docName, COUNT(ai) from ActionItem ai where ai.principalId = :principalId " + 048 "and (ai.delegationType is null or ai.delegationType != :delegationType)" 049 + " group by ai.docName")}) 050public class ActionItem extends ActionItemBase { 051 052 private static final long serialVersionUID = -1079562205125660151L; 053 054 public ActionItem deepCopy(Map<Object, Object> visited) { 055 return super.deepCopy(visited, ActionItem.class); 056 } 057 058 public static org.kuali.rice.kew.api.action.ActionItem to(ActionItem bo) { 059 if (bo == null) { 060 return null; 061 } 062 return org.kuali.rice.kew.api.action.ActionItem.Builder.create(bo).build(); 063 } 064 065 public static List<org.kuali.rice.kew.api.action.ActionItem> to(Collection<ActionItem> bos) { 066 if (bos == null) { 067 return null; 068 } 069 if (bos.isEmpty()) { 070 return new ArrayList<org.kuali.rice.kew.api.action.ActionItem>(); 071 } 072 073 List<org.kuali.rice.kew.api.action.ActionItem> dtos = new ArrayList<org.kuali.rice.kew.api.action.ActionItem>( 074 bos.size()); 075 for (ActionItem bo : bos) { 076 dtos.add(ActionItem.to(bo)); 077 } 078 return dtos; 079 } 080}