1   /* Copyright 2002-2026 CS GROUP
2    * Licensed to CS GROUP (CS) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * CS licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *   http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.orekit.files.ccsds.ndm.adm;
18  
19  import java.util.Optional;
20  
21  import org.orekit.annotation.Nullable;
22  import org.orekit.bodies.CelestialBodies;
23  import org.orekit.bodies.CelestialBody;
24  import org.orekit.files.ccsds.definitions.BodyFacade;
25  import org.orekit.files.ccsds.definitions.CcsdsFrameMapper;
26  import org.orekit.files.ccsds.section.Metadata;
27  import org.orekit.frames.Frame;
28  
29  /** This class gathers the meta-data present in the Attitude Data Message (ADM).
30   * @author Bryan Cazabonne
31   * @since 10.2
32   */
33  public class AdmMetadata extends Metadata {
34  
35      /** Spacecraft name for which the attitude data are provided. */
36      private String objectName;
37  
38      /** Object identifier of the object for which the attitude data are provided. */
39      private String objectID;
40  
41      /** Body at origin of reference frame. */
42      @Nullable
43      private BodyFacade center;
44  
45      /**
46       * Simple constructor.
47       *
48       * @param frameMapper for creating an Orekit {@link Frame}.
49       * @since 13.1.5
50       */
51      public AdmMetadata(final CcsdsFrameMapper frameMapper) {
52          super(null, frameMapper);
53      }
54  
55      /** {@inheritDoc} */
56      @Override
57      public void validate(final double version) {
58          super.validate(version);
59          checkNotNull(objectName, AdmMetadataKey.OBJECT_NAME.name());
60          checkNotNull(objectID,   AdmCommonMetadataKey.OBJECT_ID.name());
61      }
62  
63      /**
64       * Get the spacecraft name for which the attitude data are provided.
65       * @return the spacecraft name
66       */
67      public String getObjectName() {
68          return objectName;
69      }
70  
71      /**
72       * Set the spacecraft name for which the attitude data are provided.
73       * @param objectName the spacecraft name to be set
74       */
75      public void setObjectName(final String objectName) {
76          refuseFurtherComments();
77          this.objectName = objectName;
78      }
79  
80      /**
81       * Get the spacecraft ID for which the attitude data are provided.
82       * @return the spacecraft ID
83       */
84      public String getObjectID() {
85          return objectID;
86      }
87  
88      /**
89       * Set the spacecraft ID for which the attitude data are provided.
90       * @param objectID the spacecraft ID to be set
91       */
92      public void setObjectID(final String objectID) {
93          refuseFurtherComments();
94          this.objectID = objectID;
95      }
96  
97      /** Get the launch year.
98       * @return launch year
99       */
100     public int getLaunchYear() {
101         return getLaunchYear(objectID);
102     }
103 
104     /** Get the launch number.
105      * @return launch number
106      */
107     public int getLaunchNumber() {
108         return getLaunchNumber(objectID);
109     }
110 
111     /** Get the piece of launch.
112      * @return piece of launch
113      */
114     public String getLaunchPiece() {
115         return getLaunchPiece(objectID);
116     }
117 
118     /** Get the body at origin of reference frame.
119      * @return the body at origin of reference frame.
120      */
121     public Optional<BodyFacade> getCenter() {
122         return Optional.ofNullable(center);
123     }
124 
125     /** Set the body at origin of reference frame.
126      * @param center body at origin of reference frame
127      */
128     public void setCenter(final BodyFacade center) {
129         refuseFurtherComments();
130         this.center = center;
131     }
132 
133     /**
134      * Get boolean testing whether the body corresponding to the centerName
135      * attribute can be created through the {@link CelestialBodies}.
136      * @return true if {@link CelestialBody} can be created from centerName
137      *         false otherwise
138      */
139     public boolean getHasCreatableBody() {
140         return getCenter().isPresent() && getCenter().get().getBody().isPresent();
141     }
142 
143 }