/** * Creates the acquisition information object if it does not already exists, then returns it. * * @return the acquisition information (never {@code null}). * @see #newAcquisition() */ private DefaultAcquisitionInformation acquisition() { if (acquisition == null) { acquisition = new DefaultAcquisitionInformation(); } return acquisition; }
/** * Invoked by JAXB at marshalling time for getting the actual metadata to write * inside the {@code <gmi:MI_AcquisitionInformation>} XML element. * This is the value or a copy of the value given in argument to the {@code wrap} method. * * @return the metadata to be marshalled. */ @XmlElementRef public DefaultAcquisitionInformation getElement() { return DefaultAcquisitionInformation.castOrCopy(metadata); }
/** * Sets the record of the environmental circumstances during the data acquisition. * * @param newValue the new environmental record value. */ public void setEnvironmentalConditions(final EnvironmentalRecord newValue) { checkWritePermission(environmentalConditions); environmentalConditions = newValue; }
/** * Creates a metadata object having a cyclic association. The cycle is between * {@code platform.instrument} and {@code instrument.isMountedOn}. */ static DefaultAcquisitionInformation createCyclicMetadata() { final DefaultInstrument instrument = new DefaultInstrument(); instrument.setType(new SimpleInternationalString("An instrument type.")); final DefaultPlatform platform = new DefaultPlatform(); platform.setDescription(new SimpleInternationalString("A platform.")); instrument.setMountedOn(platform); platform.setInstruments(singleton(instrument)); final DefaultAcquisitionInformation acquisition = new DefaultAcquisitionInformation(); acquisition.setPlatforms(singleton(platform)); return acquisition; }
/** * Adds a platform on which instrument are installed. If a platform was already defined * with a different identifier, then a new platform instance will be created. * Storage location is: * * <ul> * <li>{@code metadata/acquisitionInformation/platform/identifier}</li> * </ul> * * @param authority identifiers the authority that define platform codes, or {@code null} if none. * @param identifier identifier of the platform to add, or {@code null} for no-operation. */ public final void addPlatform(final CharSequence authority, String identifier) { if (identifier != null && !(identifier = identifier.trim()).isEmpty()) { if (platform != null) { final Identifier current = platform.getIdentifier(); if (current != null) { if (identifier.equals(current.getCode())) { return; } acquisition().getPlatforms().add(platform); platform = null; } } platform().setIdentifier(sharedIdentifier(authority, identifier)); } }
/** * Tests the {@link MetadataStandard#equals(Object, Object, ComparisonMode)} method on an object * having cyclic associations. In absence of safety guard against infinite recursivity, this test * would produce {@link StackOverflowError}. */ @Test @DependsOnMethod("testEquals") public void testEqualsOnCyclicMetadata() { final DefaultAcquisitionInformation p1 = createCyclicMetadata(); final DefaultAcquisitionInformation p2 = createCyclicMetadata(); assertTrue("equals", p1.equals(p2)); final DefaultPlatform platform = (DefaultPlatform) getSingleton(p2.getPlatforms()); final DefaultInstrument instrument = (DefaultInstrument) getSingleton(platform.getInstruments()); instrument.setType(new SimpleInternationalString("An other instrument type.")); assertFalse("equals", p1.equals(p2)); }
/** * Adds the identifier of the operation used to acquire the dataset. * Examples: "GHRSST", "NOAA CDR", "NASA EOS", "JPSS", "GOES-R". * Storage location is: * * <ul> * <li>{@code metadata/acquisitionInformation/operation/identifier}</li> * </ul> * * @param program identification of the mission, or {@code null} if none. * @param identifier unique identification of the operation, or {@code null} for no-operation. */ public final void addAcquisitionOperation(final CharSequence program, String identifier) { if (identifier != null && !(identifier = identifier.trim()).isEmpty()) { final DefaultOperation r = new DefaultOperation(); r.setIdentifier(sharedIdentifier(program, identifier)); addIfNotPresent(acquisition().getOperations(), r); } }
/** * Adds the identifier of the requirement to be satisfied by data acquisition. * Storage location is: * * <ul> * <li>{@code metadata/acquisitionInformation/acquisitionRequirement/identifier}</li> * </ul> * * @param authority specifies the authority that define requirement codes, or {@code null} if none. * @param identifier unique name or code for the requirement, or {@code null} for no-operation. */ public final void addAcquisitionRequirement(final CharSequence authority, String identifier) { if (identifier != null && !(identifier = identifier.trim()).isEmpty()) { final DefaultRequirement r = new DefaultRequirement(); r.setIdentifier(sharedIdentifier(authority, identifier)); addIfNotPresent(acquisition().getAcquisitionRequirements(), r); } }
/** * Constructs a new instance initialized with the values from the specified metadata object. * This is a <cite>shallow</cite> copy constructor, since the other metadata contained in the * given object are not recursively copied. * * @param object the metadata to copy values from, or {@code null} if none. * * @see #castOrCopy(AcquisitionInformation) */ public DefaultAcquisitionInformation(final AcquisitionInformation object) { super(object); if (object != null) { acquisitionPlans = copyCollection(object.getAcquisitionPlans(), Plan.class); acquisitionRequirements = copyCollection(object.getAcquisitionRequirements(), Requirement.class); environmentalConditions = object.getEnvironmentalConditions(); instruments = copyCollection(object.getInstruments(), Instrument.class); objectives = copyCollection(object.getObjectives(), Objective.class); operations = copyCollection(object.getOperations(), Operation.class); platforms = copyCollection(object.getPlatforms(), Platform.class); } }
/** * Tests the {@link AbstractMetadata#hashCode()} method on an object having cyclic associations. * This is the same test than {@link MetadataStandardTest#testHashCodeOnCyclicMetadata()}, with * only a different entry point. * * @see MetadataStandardTest#testHashCodeOnCyclicMetadata() */ @Test public void testHashCodeOnCyclicMetadata() { final int code = MetadataStandardTest.createCyclicMetadata().hashCode(); assertEquals("hashCode", code, MetadataStandardTest.createCyclicMetadata().hashCode()); }
/** * Adds a platform on which instrument are installed. If a platform was already defined * with a different identifier, then a new platform instance will be created. * Storage location is: * * <ul> * <li>{@code metadata/acquisitionInformation/platform/identifier}</li> * </ul> * * @param authority identifiers the authority that define platform codes, or {@code null} if none. * @param identifier identifier of the platform to add, or {@code null} for no-operation. */ public final void addPlatform(final CharSequence authority, String identifier) { if (identifier != null && !(identifier = identifier.trim()).isEmpty()) { if (platform != null) { final Identifier current = platform.getIdentifier(); if (current != null) { if (identifier.equals(current.getCode())) { return; } acquisition().getPlatforms().add(platform); platform = null; } } platform().setIdentifier(sharedIdentifier(authority, identifier)); } }
/** * Adds the identifier of the operation used to acquire the dataset. * Examples: "GHRSST", "NOAA CDR", "NASA EOS", "JPSS", "GOES-R". * Storage location is: * * <ul> * <li>{@code metadata/acquisitionInformation/operation/identifier}</li> * </ul> * * @param program identification of the mission, or {@code null} if none. * @param identifier unique identification of the operation, or {@code null} for no-operation. */ public final void addAcquisitionOperation(final CharSequence program, String identifier) { if (identifier != null && !(identifier = identifier.trim()).isEmpty()) { final DefaultOperation r = new DefaultOperation(); r.setIdentifier(sharedIdentifier(program, identifier)); addIfNotPresent(acquisition().getOperations(), r); } }
/** * Adds the identifier of the requirement to be satisfied by data acquisition. * Storage location is: * * <ul> * <li>{@code metadata/acquisitionInformation/acquisitionRequirement/identifier}</li> * </ul> * * @param authority specifies the authority that define requirement codes, or {@code null} if none. * @param identifier unique name or code for the requirement, or {@code null} for no-operation. */ public final void addAcquisitionRequirement(final CharSequence authority, String identifier) { if (identifier != null && !(identifier = identifier.trim()).isEmpty()) { final DefaultRequirement r = new DefaultRequirement(); r.setIdentifier(sharedIdentifier(authority, identifier)); addIfNotPresent(acquisition().getAcquisitionRequirements(), r); } }
/** * Constructs a new instance initialized with the values from the specified metadata object. * This is a <cite>shallow</cite> copy constructor, since the other metadata contained in the * given object are not recursively copied. * * @param object the metadata to copy values from, or {@code null} if none. * * @see #castOrCopy(AcquisitionInformation) */ public DefaultAcquisitionInformation(final AcquisitionInformation object) { super(object); if (object != null) { acquisitionPlans = copyCollection(object.getAcquisitionPlans(), Plan.class); acquisitionRequirements = copyCollection(object.getAcquisitionRequirements(), Requirement.class); environmentalConditions = object.getEnvironmentalConditions(); instruments = copyCollection(object.getInstruments(), Instrument.class); objectives = copyCollection(object.getObjectives(), Objective.class); operations = copyCollection(object.getOperations(), Operation.class); platforms = copyCollection(object.getPlatforms(), Platform.class); } }
/** * Creates the acquisition information object if it does not already exists, then returns it. * * @return the acquisition information (never {@code null}). * @see #newAcquisition() */ private DefaultAcquisitionInformation acquisition() { if (acquisition == null) { acquisition = new DefaultAcquisitionInformation(); } return acquisition; }
/** * Commits all pending information under the metadata "acquisition" node (station, sensors, <i>etc</i>). * If there is no pending acquisition information, then invoking this method has no effect. * If new acquisition info are added after this method call, they will be stored in a new element. * * <p>This method does not need to be invoked unless a new "acquisition info" node, * separated from the previous one, is desired.</p> */ public final void newAcquisition() { if (platform != null) { addIfNotPresent(acquisition().getPlatforms(), platform); } if (acquisition != null) { addIfNotPresent(metadata().getAcquisitionInformation(), acquisition); acquisition = null; } }
/** * Adds an event that describe the time at which data were acquired. * Storage location is: * * <ul> * <li>{@code metadata/acquisitionInformation/operation/significantEvent/time}</li> * </ul> * * @param time the acquisition time, or {@code null} for no-operation. * * @see #addTemporalExtent(Date, Date) */ public final void addAcquisitionTime(final Date time) { if (time != null) { final DefaultEvent event = new DefaultEvent(); event.setContext(Context.ACQUISITION); event.setTime(time); final DefaultOperation op = new DefaultOperation(); op.setSignificantEvents(singleton(event)); op.setType(OperationType.REAL); op.setStatus(Progress.COMPLETED); addIfNotPresent(acquisition().getOperations(), op); } }
/** * Invoked by JAXB at marshalling time for getting the actual metadata to write * inside the {@code <mac:MI_AcquisitionInformation>} XML element. * This is the value or a copy of the value given in argument to the {@code wrap} method. * * @return the metadata to be marshalled. */ @XmlElementRef public DefaultAcquisitionInformation getElement() { return DefaultAcquisitionInformation.castOrCopy(metadata); }
/** * Sets the record of the environmental circumstances during the data acquisition. * * @param newValue the new environmental record value. */ public void setEnvironmentalConditions(final EnvironmentalRecord newValue) { checkWritePermission(); environmentalConditions = newValue; }
/** * Returns a SIS metadata implementation with the values of the given arbitrary implementation. * This method performs the first applicable action in the following choices: * * <ul> * <li>If the given object is {@code null}, then this method returns {@code null}.</li> * <li>Otherwise if the given object is already an instance of * {@code DefaultAcquisitionInformation}, then it is returned unchanged.</li> * <li>Otherwise a new {@code DefaultAcquisitionInformation} instance is created using the * {@linkplain #DefaultAcquisitionInformation(AcquisitionInformation) copy constructor} * and returned. Note that this is a <cite>shallow</cite> copy operation, since the other * metadata contained in the given object are not recursively copied.</li> * </ul> * * @param object the object to get as a SIS implementation, or {@code null} if none. * @return a SIS implementation containing the values of the given object (may be the * given object itself), or {@code null} if the argument was null. */ public static DefaultAcquisitionInformation castOrCopy(final AcquisitionInformation object) { if (object == null || object instanceof DefaultAcquisitionInformation) { return (DefaultAcquisitionInformation) object; } return new DefaultAcquisitionInformation(object); }