View Javadoc
1   /*
2    * Copyright 2017 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.openehealth.ipf.commons.ihe.xds.core.requests;
17  
18  import lombok.EqualsAndHashCode;
19  import lombok.Getter;
20  import lombok.ToString;
21  import org.openehealth.ipf.commons.ihe.xds.core.metadata.DocumentEntry;
22  
23  import javax.xml.bind.annotation.XmlElementRef;
24  import java.io.Serializable;
25  import java.util.ArrayList;
26  import java.util.List;
27  
28  /**
29   * Base class for non-constructive operations (Read+Delete as opposed to Create+Update in CRUD)
30   * on document sets in an XDS Repository.
31   * <p>
32   * Lists are pre-created and can therefore never be <code>null</code>.
33   * @since 3.3
34   */
35  @EqualsAndHashCode(doNotUseGetters = true)
36  @ToString(doNotUseGetters = true)
37  abstract public class NonconstructiveDocumentSetRequest implements Serializable {
38      private static final long serialVersionUID = 4812212416179958948L;
39  
40      @XmlElementRef
41      @Getter private final List<DocumentReference> documents = new ArrayList<>();
42  
43      /**
44       * Adds the document, represented by the given document entry, to the list of referenced documents.
45       * @param documentEntry document entry.
46       */
47      public void addReferenceTo(DocumentEntry documentEntry) {
48          documents.add(new DocumentReference(
49                  documentEntry.getRepositoryUniqueId(),
50                  documentEntry.getUniqueId(),
51                  documentEntry.getHomeCommunityId()));
52      }
53  }