Search in sources :

Example 1 with DefaultInstrument

use of org.apache.sis.metadata.iso.acquisition.DefaultInstrument in project sis by apache.

the class MetadataStandardTest method testEqualsOnCyclicMetadata.

/**
 * 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));
}
Also used : DefaultAcquisitionInformation(org.apache.sis.metadata.iso.acquisition.DefaultAcquisitionInformation) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) DefaultPlatform(org.apache.sis.metadata.iso.acquisition.DefaultPlatform) DefaultInstrument(org.apache.sis.metadata.iso.acquisition.DefaultInstrument) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 2 with DefaultInstrument

use of org.apache.sis.metadata.iso.acquisition.DefaultInstrument in project sis by apache.

the class MetadataBuilder method addInstrument.

/**
 * Adds an instrument or sensor on the platform.
 * Storage location is:
 *
 * <ul>
 *   <li>{@code metadata/acquisitionInformation/platform/instrument/identifier}</li>
 * </ul>
 *
 * @param  authority   identifiers the authority that define instrument codes, or {@code null} if none.
 * @param  identifier  identifier of the sensor to add, or {@code null} for no-operation.
 */
public final void addInstrument(final CharSequence authority, String identifier) {
    if (identifier != null && !(identifier = identifier.trim()).isEmpty()) {
        final DefaultInstrument instrument = new DefaultInstrument();
        instrument.setIdentifier(sharedIdentifier(authority, identifier));
        addIfNotPresent(platform().getInstruments(), instrument);
    }
}
Also used : DefaultInstrument(org.apache.sis.metadata.iso.acquisition.DefaultInstrument)

Example 3 with DefaultInstrument

use of org.apache.sis.metadata.iso.acquisition.DefaultInstrument in project sis by apache.

the class MetadataStandardTest method createCyclicMetadata.

/**
 * 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;
}
Also used : SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) DefaultAcquisitionInformation(org.apache.sis.metadata.iso.acquisition.DefaultAcquisitionInformation) DefaultPlatform(org.apache.sis.metadata.iso.acquisition.DefaultPlatform) DefaultInstrument(org.apache.sis.metadata.iso.acquisition.DefaultInstrument)

Aggregations

DefaultInstrument (org.apache.sis.metadata.iso.acquisition.DefaultInstrument)3 DefaultAcquisitionInformation (org.apache.sis.metadata.iso.acquisition.DefaultAcquisitionInformation)2 DefaultPlatform (org.apache.sis.metadata.iso.acquisition.DefaultPlatform)2 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)2 DependsOnMethod (org.apache.sis.test.DependsOnMethod)1 Test (org.junit.Test)1