Skip to content

Commit

Permalink
Merge ea09b66 into fc99a46
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeEdgar committed May 11, 2020
2 parents fc99a46 + ea09b66 commit 7991da0
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>io.xlate</groupId>
<artifactId>staedi</artifactId>
<version>1.4.2-SNAPSHOT</version>
<version>1.5.0-SNAPSHOT</version>

<name>StAEDI : Streaming API for EDI for Java</name>
<description>Streaming API for EDI for Java</description>
Expand Down Expand Up @@ -106,6 +106,13 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<archive>
<manifestEntries>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ public Schema createSchema(URL location) throws EDISchemaException {
}
}

@Override
public Schema getControlSchema(String standard, String[] version) throws EDISchemaException {
return SchemaUtils.getControlSchema(standard, version);
}

@Override
public boolean isPropertySupported(String name) {
return supportedProperties.contains(name);
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/io/xlate/edi/schema/SchemaFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ public static SchemaFactory newFactory() {

public abstract Schema createSchema(InputStream stream) throws EDISchemaException;

/**
* Retrieve the control schema for the provided standard and version. This method
* loads an internal, immutable schema provided by StAEDI.
*
* @param standard the standard, e.g. X12 or EDIFACT
* @param version the version of the standard
* @return the control schema corresponding to the standard and version
* @throws EDISchemaException when the schema can not be loaded.
*
* @since 1.5
*/
public Schema getControlSchema(String standard, String[] version) throws EDISchemaException;

/**
* Query the set of properties that this factory supports.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.junit.jupiter.api.Test;

import io.xlate.edi.schema.EDISchemaException;
import io.xlate.edi.schema.EDIType;
import io.xlate.edi.schema.Schema;
import io.xlate.edi.schema.SchemaFactory;
import io.xlate.edi.stream.EDIStreamConstants.Standards;
Expand Down Expand Up @@ -253,4 +254,14 @@ public void testDuplicateElementTypeNames() {
assertNotNull(cause);
assertEquals("duplicate name: DE0004", cause.getMessage());
}

@Test
public void testGetControlSchema() throws EDISchemaException {
SchemaFactory factory = SchemaFactory.newFactory();
Schema schema = factory.getControlSchema(Standards.X12, new String[] { "00501" });
assertNotNull(schema);
assertEquals(EDIType.Type.SEGMENT, schema.getType("ISA").getType());
assertEquals(EDIType.Type.SEGMENT, schema.getType("GS").getType());
assertEquals(EDIType.Type.SEGMENT, schema.getType("ST").getType());
}
}

0 comments on commit 7991da0

Please sign in to comment.