001/* 002 * Copyright (c) 2006-2013 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 * 009 * Contributors: 010 * Vladimir Pasquier <vpasquier@nuxeo.com> 011 * Stéphane Lacoin <slacoin@nuxeo.com> 012 */ 013package org.nuxeo.ecm.automation.core.operations.business; 014 015import org.nuxeo.ecm.automation.core.Constants; 016import org.nuxeo.ecm.automation.core.annotations.Context; 017import org.nuxeo.ecm.automation.core.annotations.Operation; 018import org.nuxeo.ecm.automation.core.annotations.OperationMethod; 019import org.nuxeo.ecm.automation.core.operations.business.adapter.BusinessAdapter; 020import org.nuxeo.ecm.core.api.CoreSession; 021import org.nuxeo.ecm.core.api.DocumentModel; 022import org.nuxeo.ecm.core.api.IdRef; 023 024/** 025 * This operation map pojo client side to document adapter server side and fetch the related NX document. 026 * 027 * @since 5.7 028 */ 029@Operation(id = BusinessFetchOperation.ID, category = Constants.CAT_BUSINESS, label = "BusinessFetchOperation", description = "This operation map pojo client side to document adapter server side and fetch the related NX document.", addToStudio = false) 030public class BusinessFetchOperation { 031 032 public static final String ID = "Business.BusinessFetchOperation"; 033 034 @Context 035 protected CoreSession session; 036 037 @OperationMethod 038 public BusinessAdapter run(BusinessAdapter input) throws ClassNotFoundException { 039 DocumentModel document = session.getDocument(new IdRef(input.getId())); 040 return document.getAdapter(input.getClass()); 041 } 042}