Skip to content

Commit

Permalink
Site and site generation cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesagnew committed Jan 21, 2013
1 parent f43e18d commit c89a787
Show file tree
Hide file tree
Showing 26 changed files with 682 additions and 127 deletions.
16 changes: 8 additions & 8 deletions hapi-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,42 +29,42 @@
<dependency>
<groupId>ca.uhn.hapi</groupId>
<artifactId>hapi-structures-v21</artifactId>
<version>${hapi.version.structures}</version>
<version>${hapi.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi</groupId>
<artifactId>hapi-structures-v22</artifactId>
<version>${hapi.version.structures}</version>
<version>${hapi.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi</groupId>
<artifactId>hapi-structures-v23</artifactId>
<version>${hapi.version.structures}</version>
<version>${hapi.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi</groupId>
<artifactId>hapi-structures-v231</artifactId>
<version>${hapi.version.structures}</version>
<version>${hapi.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi</groupId>
<artifactId>hapi-structures-v24</artifactId>
<version>${hapi.version.structures}</version>
<version>${hapi.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi</groupId>
<artifactId>hapi-structures-v25</artifactId>
<version>${hapi.version.structures}</version>
<version>${hapi.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi</groupId>
<artifactId>hapi-structures-v251</artifactId>
<version>${hapi.version.structures}</version>
<version>${hapi.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi</groupId>
<artifactId>hapi-structures-v26</artifactId>
<version>${hapi.version.structures}</version>
<version>${hapi.version}</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,54 @@
import ca.uhn.hl7v2.HL7Exception;
import ca.uhn.hl7v2.examples.custommodel.v25.segment.ZPI;
import ca.uhn.hl7v2.model.v25.message.ADT_A01;
import ca.uhn.hl7v2.parser.DefaultModelClassFactory;
import ca.uhn.hl7v2.parser.ModelClassFactory;
import java.util.Arrays;

/**
* Example custom model class. This is a ZDT^A01, which is an ADT^A01 with
* an extra ZPI segment after the PID segment
*
* Since we're extending an existing HL7 message type, we just extend from the model class
* representing that type
* Example custom model class. This is a ZDT^A01, which is an ADT^A01 with an
* extra ZPI segment after the PID segment
*
* Since we're extending an existing HL7 message type, we just extend from the
* model class representing that type
*/
@SuppressWarnings("serial")
public class ZDT_A01 extends ADT_A01 {

/**
* Constructor
*
* We always have to have a constructor with this one argument
*/
public ZDT_A01(ModelClassFactory factory) throws HL7Exception {
super(factory);

// Now, let's add the ZPI segment at the right spot
String[] segmentNames = getNames();
int indexOfPid = Arrays.asList(segmentNames).indexOf("PID");

// Put the ZPI segment right after the PID segment
int index = indexOfPid + 1;

Class<ZPI> type = ZPI.class;
boolean required = true;
boolean repeating = false;

this.add(type, required, repeating, index);
}


/**
* Add an accessor for the ZPI segment
*/
public ZPI getZPI() throws HL7Exception {
return getTyped("ZPI", ZPI.class);
}
/**
* Constructor
*/
public ZDT_A01() throws HL7Exception {
this(new DefaultModelClassFactory());
}

/**
* Constructor
*
* We always have to have a constructor with this one argument
*/
public ZDT_A01(ModelClassFactory factory) throws HL7Exception {
super(factory);

// Now, let's add the ZPI segment at the right spot
String[] segmentNames = getNames();
int indexOfPid = Arrays.asList(segmentNames).indexOf("PID");

// Put the ZPI segment right after the PID segment
int index = indexOfPid + 1;

Class<ZPI> type = ZPI.class;
boolean required = true;
boolean repeating = false;

this.add(type, required, repeating, index);
}

/**
* Add an accessor for the ZPI segment
*/
public ZPI getZPI() throws HL7Exception {
return getTyped("ZPI", ZPI.class);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package ca.uhn.hl7v2.examples.sourcegen;

import java.io.IOException;

import ca.uhn.hl7v2.DefaultHapiContext;
import ca.uhn.hl7v2.HL7Exception;
import ca.uhn.hl7v2.app.Connection;
import ca.uhn.hl7v2.app.HL7Service;
import ca.uhn.hl7v2.examples.custommodel.v25.message.ZDT_A01;
import ca.uhn.hl7v2.llp.LLPException;
import ca.uhn.hl7v2.model.Message;
import ca.uhn.hl7v2.parser.CanonicalModelClassFactory;
import ca.uhn.hl7v2.parser.ModelClassFactory;

public class ExampleUseConfGen {

public static void main(String[] args) throws HL7Exception, IOException, LLPException {
// Sending a message

{
// Create a new instance of the message and initialize it
ZDT_A01 outMsg = new ZDT_A01();
outMsg.initQuickstart("ZDT", "A01", "T");

// .. populate other segments ..
// e.g. outMsg.getPID().getPid3_PatientIdentifierList(0).......

// Create a hapi context and send the message
DefaultHapiContext ctx = new DefaultHapiContext();
Connection conn = ctx.newClient("someserver.com", 8888, false);

// Send the message
Message response = conn.getInitiator().sendAndReceive(outMsg);
}


DefaultHapiContext ctx = new DefaultHapiContext();
ModelClassFactory mcf = new CanonicalModelClassFactory(ZDT_A01.class);
ctx.setModelClassFactory(mcf);

HL7Service server = ctx.newServer(8888, false);
server.start();

}



}
10 changes: 8 additions & 2 deletions hapi-sourcegen/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@

<build>
<plugins>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
<version>${maven.plugin.plugin.version}</version>
<configuration>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
Expand All @@ -126,14 +132,14 @@
<plugins>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
<version>2.5</version>
<version>${maven.plugin.plugin.version}</version>
<configuration>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.1.2</version>
<version>${maven.project.info.plugin.version}</version>
<reportSets>
<reportSet>
<reports>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class ClassicConfGenMojo extends AbstractMojo
/**
* The maven project.
*
* @parameter expression="${project}"
* @parameter property="project"
* @required
* @readonly
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,35 +42,9 @@ GNU General Public License (the �GPL�), in which case the provisions of the
import ca.uhn.hl7v2.sourcegen.conf.ProfileSourceGenerator;

/**
* <p>
* Maven Plugin Mojo for generating HAPI message structure classes which are based on
* an HL7 conformance profile file. For more information on this plugin, see
* <a href="http://hl7api.sourceforge.net/conformance.html">here</a>.
* </p>
* <p>
* Usage is as follows:
* </p>
* <pre>
* &lt;plugin&gt;
* &lt;groupId&gt;ca.uhn.hapi&lt;/groupId&gt;
* &lt;artifactId&gt;hapi-sourcegen&lt;/artifactId&gt;
* &lt;version&gt;2.0&lt;/version&gt;
* &lt;executions&gt;
* &lt;execution&gt;
* &lt;id&gt;build&lt;/id&gt;
* &lt;goals&gt;
* &lt;goal&gt;confgen&lt;/goal&gt;
* &lt;/goals&gt;
* &lt;configuration&gt;
* &lt;targetDirectory&gt;${basedir}/target/generated-sources/confgen&lt;/targetDirectory&gt;
* &lt;packageName&gt;ca.uhn.hl7v2.test.nodt.conf&lt;/packageName&gt;
* &lt;profile&gt;${basedir}/src/test/resources/ca/uhn/hl7v2/conf/parser/ADT_A01.xml&lt;/profile&gt;
* &lt;generateDateTypes&gt;NONE&lt;/generateDateTypes&gt;
* &lt;/configuration&gt;
* &lt;/execution&gt;
* &lt;/execution&gt;
* &lt;/plugin&gt;
* </pre>
* Maven Plugin for generating HAPI message structure classes which are based on
* an HL7 conformance profile file. For more information on using this plugin, see
* the <a href="confgen-usage.html">Confgen Usage</a> page.
*
* @author <a href="mailto:[email protected]">James Agnew</a>
* @goal confgen
Expand All @@ -84,7 +58,7 @@ public class ConfGenMojo extends AbstractMojo {
/**
* The maven project.
*
* @parameter expression="${project}"
* @parameter property="project"
* @required
* @readonly
*/
Expand All @@ -107,17 +81,15 @@ public class ConfGenMojo extends AbstractMojo {
String profile;

/**
* The package for the generated source
* The package for the generated source, e.g. "com.acme.hl7structure.adt"
*
* @parameter
* @required
*/
String packageName;

/**
* <p>
* Should data types be generated. Valid options are:
* </p>
* <ul>
* <li><b>NONE</b>: Do not generate custom data types, use HAPI's normal
* data type classes for the HL7 version that the profile corresponds to
Expand Down Expand Up @@ -149,17 +121,13 @@ public class ConfGenMojo extends AbstractMojo {

/**
* Should structures be treated as resources
*
* @parameter default="false"
*/
boolean structuresAsResources;
private boolean structuresAsResources;

/**
* Should structures be treated as resources
*
* @parameter default="java"
* File extension for the generated source files.
*/
String fileExt = "java";
private String fileExt = "java";

/**
* {@inheritDoc}
Expand Down
Loading

0 comments on commit c89a787

Please sign in to comment.