This project has retired. For details please refer to its Attic page.
TransientRelationshipImpl xref

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.chemistry.opencmis.client.runtime;
20  
21  import org.apache.chemistry.opencmis.client.api.CmisObject;
22  import org.apache.chemistry.opencmis.client.api.ObjectId;
23  import org.apache.chemistry.opencmis.client.api.OperationContext;
24  import org.apache.chemistry.opencmis.client.api.TransientRelationship;
25  import org.apache.chemistry.opencmis.commons.PropertyIds;
26  
27  public class TransientRelationshipImpl extends AbstractTransientCmisObject implements TransientRelationship {
28  
29      public CmisObject getSource() {
30          return getSource(getSession().getDefaultContext());
31      }
32  
33      public CmisObject getSource(OperationContext context) {
34          return getSession().getObject(getSourceId(), context);
35      }
36  
37      public ObjectId getSourceId() {
38          String sourceId = getPropertyValue(PropertyIds.SOURCE_ID);
39          if ((sourceId == null) || (sourceId.length() == 0)) {
40              return null;
41          }
42  
43          return getSession().createObjectId(sourceId);
44      }
45  
46      public void setSourceId(ObjectId id) {
47          if ((id == null) || (id.getId() == null) || (id.getId().length() == 0)) {
48              throw new IllegalArgumentException("Id is invalid!");
49          }
50  
51          setPropertyValue(PropertyIds.SOURCE_ID, id.getId());
52      }
53  
54      public CmisObject getTarget() {
55          return getTarget(getSession().getDefaultContext());
56      }
57  
58      public CmisObject getTarget(OperationContext context) {
59          return getSession().getObject(getTargetId(), context);
60      }
61  
62      public ObjectId getTargetId() {
63          String targetId = getPropertyValue(PropertyIds.TARGET_ID);
64          if ((targetId == null) || (targetId.length() == 0)) {
65              return null;
66          }
67  
68          return getSession().createObjectId(targetId);
69      }
70  
71      public void setTargetId(ObjectId id) {
72          if ((id == null) || (id.getId() == null) || (id.getId().length() == 0)) {
73              throw new IllegalArgumentException("Id is invalid!");
74          }
75  
76          setPropertyValue(PropertyIds.TARGET_ID, id.getId());
77      }
78  }