001/* 002 * (C) Copyright 2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0 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 * 016 * Contributors: 017 * ldoguin 018 */ 019package org.nuxeo.ecm.platform.routing.dm.adapter; 020 021import java.util.Calendar; 022import java.util.Date; 023import java.util.List; 024 025import org.nuxeo.ecm.core.api.DocumentModel; 026import org.nuxeo.ecm.platform.routing.dm.api.RoutingTaskConstants; 027 028/** 029 * @deprecated since 5.9.2 - Use only routes of type 'graph' 030 */ 031@Deprecated 032public class TaskStepImpl implements TaskStep { 033 034 protected DocumentModel doc; 035 036 public TaskStepImpl(DocumentModel doc) { 037 this.doc = doc; 038 } 039 040 @Override 041 public DocumentModel getDocument() { 042 return doc; 043 } 044 045 @Override 046 public String getId() { 047 return doc.getId(); 048 } 049 050 @Override 051 public List<String> getActors() { 052 return getPropertyValue(RoutingTaskConstants.TASK_STEP_ACTORS_PROPERTY_NAME); 053 } 054 055 @Override 056 public String getName() { 057 return doc.getTitle(); 058 } 059 060 @Override 061 public String getDirective() { 062 return getPropertyValue(RoutingTaskConstants.TASK_STEP_DIRECTIVE_PROPERTY_NAME); 063 } 064 065 @SuppressWarnings("unchecked") 066 @Override 067 public List<String> getComments() { 068 return (List<String>) getPropertyValue(RoutingTaskConstants.TASK_STEP_COMMENTS_PROPERTY_NAME); 069 } 070 071 @Override 072 public Date getDueDate() { 073 return getDatePropertyValue(RoutingTaskConstants.TASK_STEP_DUE_DATE_PROPERTY_NAME); 074 } 075 076 @Override 077 public Boolean hasAutomaticValidation() { 078 return getPropertyValue(RoutingTaskConstants.TASK_STEP_AUTOMATIC_VALIDATION_PROPERTY_NAME); 079 } 080 081 @SuppressWarnings("unchecked") 082 protected <T> T getPropertyValue(String propertyName) { 083 return (T) doc.getPropertyValue(propertyName); 084 } 085 086 protected Date getDatePropertyValue(String propertyName) { 087 Calendar cal = (Calendar) doc.getPropertyValue(propertyName); 088 if (cal != null) { 089 return cal.getTime(); 090 } 091 return null; 092 } 093 094}