001/*
002 * (C) Copyright 2011 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     ldoguin
016 */
017package org.nuxeo.ecm.platform.routing.dm.adapter;
018
019import org.nuxeo.ecm.automation.task.CreateTask.OperationTaskVariableName;
020import org.nuxeo.ecm.core.api.CoreSession;
021import org.nuxeo.ecm.core.api.DocumentModel;
022import org.nuxeo.ecm.core.api.DocumentModelList;
023import org.nuxeo.ecm.core.api.DocumentRef;
024import org.nuxeo.ecm.core.api.IdRef;
025import org.nuxeo.ecm.core.api.impl.DocumentModelListImpl;
026import org.nuxeo.ecm.platform.routing.api.DocumentRouteStep;
027import org.nuxeo.ecm.platform.routing.api.DocumentRoutingConstants;
028import org.nuxeo.ecm.platform.task.TaskImpl;
029
030/**
031 * @deprecated since 5.9.2 - Use only routes of type 'graph' The facet 'RoutingTask' is still used to mark tasks created
032 *             by the workflow, but it this class is marked as deprecated as it extends the deprecated ActionableObject
033 */
034@Deprecated
035public class RoutingTaskImpl extends TaskImpl implements RoutingTask {
036
037    public RoutingTaskImpl(DocumentModel doc) {
038        super(doc);
039    }
040
041    private static final long serialVersionUID = 1L;
042
043    /**
044     * @deprecated {@link Task#getTargetDocumentsIds() } should be used instead
045     */
046    @Deprecated
047    @Override
048    public DocumentModelList getAttachedDocuments(CoreSession coreSession) {
049        DocumentRef stepIdRef = new IdRef(getTargetDocumentId());
050        DocumentModel targetDocument = coreSession.getDocument(stepIdRef);
051        DocumentModelList docList = new DocumentModelListImpl();
052        docList.add(targetDocument);
053        return docList;
054    }
055
056    @Override
057    public DocumentRouteStep getDocumentRouteStep(CoreSession coreSession) {
058        String docStepId = getVariable(DocumentRoutingConstants.OPERATION_STEP_DOCUMENT_KEY);
059        DocumentRef stepIdRef = new IdRef(docStepId);
060        DocumentModel docStep = coreSession.getDocument(stepIdRef);
061        return docStep.getAdapter(DocumentRouteStep.class);
062    }
063
064    @Override
065    public String getRefuseOperationChainId() {
066        return getVariable(OperationTaskVariableName.rejectOperationChain.name());
067    }
068
069    @Override
070    public String getValidateOperationChainId() {
071        return getVariable(OperationTaskVariableName.acceptOperationChain.name());
072    }
073
074}