001/* 002 * Copyright (c) 2006-2011 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 * Florent Guillaume 011 */ 012package org.nuxeo.ecm.core.opencmis.impl.client; 013 014import org.apache.chemistry.opencmis.client.api.CmisObject; 015import org.apache.chemistry.opencmis.client.api.ObjectId; 016import org.apache.chemistry.opencmis.client.api.ObjectType; 017import org.apache.chemistry.opencmis.client.api.OperationContext; 018import org.apache.chemistry.opencmis.client.api.Relationship; 019import org.apache.chemistry.opencmis.commons.PropertyIds; 020import org.nuxeo.ecm.core.opencmis.impl.server.NuxeoObjectData; 021 022/** 023 * Live local CMIS Relationship, which is backed by a Nuxeo document. 024 */ 025public class NuxeoRelationship extends NuxeoObject implements Relationship { 026 027 public NuxeoRelationship(NuxeoSession session, NuxeoObjectData data, ObjectType type) { 028 super(session, data, type); 029 } 030 031 @Override 032 public ObjectId getSourceId() { 033 String id = getPropertyValue(PropertyIds.SOURCE_ID); 034 return id == null ? null : session.createObjectId(id); 035 } 036 037 @Override 038 public CmisObject getSource() { 039 String id = getPropertyValue(PropertyIds.SOURCE_ID); 040 return id == null ? null : session.getObject(session.createObjectId(id)); 041 } 042 043 @Override 044 public CmisObject getSource(OperationContext context) { 045 String id = getPropertyValue(PropertyIds.SOURCE_ID); 046 return id == null ? null : session.getObject(session.createObjectId(id), context); 047 } 048 049 @Override 050 public ObjectId getTargetId() { 051 String id = getPropertyValue(PropertyIds.TARGET_ID); 052 return id == null ? null : session.createObjectId(id); 053 } 054 055 @Override 056 public CmisObject getTarget() { 057 String id = getPropertyValue(PropertyIds.TARGET_ID); 058 return id == null ? null : session.getObject(session.createObjectId(id)); 059 } 060 061 @Override 062 public CmisObject getTarget(OperationContext context) { 063 String id = getPropertyValue(PropertyIds.TARGET_ID); 064 return id == null ? null : session.getObject(session.createObjectId(id), context); 065 } 066 067}