Permalink
Browse files

Worked on SOR HealthInstitution and eliminated some todos

  • Loading branch information...
1 parent dc7739d commit 7b63c62c4dfa2593c79fbd69c2abedf3546166ee unknown committed May 3, 2012
View
Binary file not shown.
@@ -34,6 +34,7 @@
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
+import com.trifork.stamdata.importer.jobs.sor.sor2.xmlmodel.ClinicalSpeciality;
import com.trifork.stamdata.importer.jobs.sor.sor2.xmlmodel.EanLocationCode;
import com.trifork.stamdata.importer.jobs.sor.sor2.xmlmodel.OrganizationalUnit;
import com.trifork.stamdata.importer.jobs.sor.sor2.xmlmodel.PostalAddressInformation;
@@ -88,6 +89,10 @@ else if (SORXmlTagNames.ADDRESS_POSTAL.equals(qName))
{
currentNode = new PostalAddressInformation(atts, currentNode, lastTag);
}
+ else if (SORXmlTagNames.CLINICAL_SPECIALITY.equals(qName))
+ {
+ currentNode = new ClinicalSpeciality(atts, currentNode, lastTag);
+ }
lastTag = qName;
super.startElement(uri, localName, qName, atts);
@@ -103,7 +108,7 @@ public void endElement(String uri, String localName, String qName) throws SAXExc
if (currentNode.isUniqueKey()) {
try {
currentNode.compareAgainstDatabaseAndUpdateDirty(fetcher);
- currentNode.persist(persister);
+ currentNode.persistRecursive(persister);
if (parent != null) {
parent.removeChild(currentNode);
}
@@ -30,8 +30,6 @@
public static final String INSTITUTION_OWNER_ENTITY = "InstitutionOwnerEntity";
public static final String INSTITUTION_OWNER = "InstitutionOwner";
//
- public static final String SOR_IDENTIFIER = "SorIdentifier";
- public static final String ENTITY_NAME = "EntityName";
public static final String OWNER_TYPE = "OwnerType";
public static final String SOR_STATUS = "SorStatus";
@@ -46,6 +44,23 @@
public static final String SPECIALITY_CODE = "SpecialityCode";
public static final String SPECIALITY_TYPE = "SpecialityType";
};
+
+ public static final String HEALTH_INSTITUTION = "HealthInstitution";
+ public class HealthInstitution {
+ public static final String SOR_IDENTIFIER = "SorIdentifier";
+ public static final String ENTITY_NAME = "EntityName";
+ public static final String INSTITUTION_TYPE = "InstitutionType";
+ public static final String PHARMACY_IDENTIFIER = "PharmacyIdentifier";
+ public static final String SHAK_IDENTIFIER = "ShakIdentifier";
+ public static final String OPTIONAL_EAN_LOCATION_CODE = "OptionalEanLocationCode";
+ public static final String GEOGRAPHICAL_PARENT = "GeographicalParent";
+ public static final String POSTAL_ADDRESS_INFO = "PostalAddressInformation";
+ public static final String VISITING_ADDRESS_INFO = "VisitingAddressInformation";
+ public static final String VIRTUAL_ADDRESS_INFO = "VirtualAddressInformation";
+ public static final String SOR_STATUS = "SorStatus";
+ public static final String REPLACES_ENTITY_COLLECTION = "ReplacesEntityCollection"; // TODO
+ public static final String REPLACED_BY_ENTITY_COLLECTION = "ReplacedByEntityCollection"; // TODO
+ };
public static final String VIRTUAL_ADDRESS_INFO = "VirtualAddressInformation";
public class VirtualAddressInformation {
@@ -109,7 +124,7 @@
public static final String VISITING_ADDRESS_INFO = "VisitingAddressInformation";
public static final String ACTIVITY_ADDRESS_INFO = "ActivityAddressInformation";
public static final String VIRTUAL_ADDRESS_INFO = "VirtualAddressInformation";
- public static final String CLINICAL_SPECIALITY_COLLECTION = "ClinicalSpecialityCollection"; // TODO
+ public static final String CLINICAL_SPECIALITY_COLLECTION = "ClinicalSpecialityCollection";
public static final String SOR_STATUS = "SorStatus";
public static final String REPLACES_ENTITY_COLLECTION = "ReplacesEntityCollection"; // TODO
@@ -130,6 +145,4 @@
public static final String LOCAL_ATTRBIBUTE5 = "LocalAttribute1";
};
- // HEALTH_INSTITUTION
- public static final String HEALTH_INSTITUTION = "HealthInstitution";
}
@@ -42,6 +42,7 @@
public ClinicalSpeciality(Attributes attribs, SorNode parent, String parentTag) {
super(attribs, parent, parentTag);
+ persistDependsOnParent = true;
}
@Override
@@ -50,18 +51,21 @@ public boolean parseEndTag(String tagName, String tagValue) throws SAXException
return true;
}
if (SORXmlTagNames.ClinicalSpeciality.SPECIALITY_CODE.equals(tagName)) {
- builder.field("specialityCode", tagValue);
+ builder.field("specialityCode", Long.valueOf(tagValue));
} else if (SORXmlTagNames.ClinicalSpeciality.SPECIALITY_TYPE.equals(tagName)) {
- builder.field("specialityType", tagValue);
+ builder.field("specialityType", Long.valueOf(tagValue));
} else {
throw new SAXException("Encountered an unexpected tag '" + tagName + "' in SorStatus");
}
return false;
}
+ public void setOrganizationalOwner(Long ownerPID) {
+ builder.field("fkOrganizationalUnit", ownerPID);
+ }
+
@Override
- public void persist(RecordPersister persister) throws SQLException {
- super.persist(persister);
+ public void persistCurrentNode(RecordPersister persister) throws SQLException {
Long id = persister.persist(builder.build(), SorFullRecordSpecs.CLINICAL_SPECIALITY);
if (id == null)
{
@@ -85,7 +85,7 @@ public boolean parseEndTag(String tagName, String tagValue) throws SAXException
* Must happen right after persist has been called on all children, to
* make sure we insert an correct id
*/
- private void updateForeignKeys() {
+ private void updateForeignKeysOneToOne() {
for (SorNode node : children) {
if (node.getClass() == SorStatus.class) {
builder.field("fkSorStatus", ((SorStatus)node).getPID());
@@ -94,9 +94,8 @@ private void updateForeignKeys() {
}
@Override
- public void persist(RecordPersister persister) throws SQLException {
- super.persist(persister);
- updateForeignKeys();
+ public void persistCurrentNode(RecordPersister persister) throws SQLException {
+ updateForeignKeysOneToOne();
persister.persist(builder.build(), SorFullRecordSpecs.EAN_LOCATION_CODE_ENTITY);
}
@@ -26,109 +26,50 @@
package com.trifork.stamdata.importer.jobs.sor.sor2.xmlmodel;
-import java.util.List;
+import java.sql.SQLException;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import com.trifork.stamdata.importer.jobs.sor.sor2.SORXmlTagNames;
+import com.trifork.stamdata.persistence.RecordBuilder;
+import com.trifork.stamdata.persistence.RecordFetcher;
+import com.trifork.stamdata.persistence.RecordPersister;
+import com.trifork.stamdata.specs.SorFullRecordSpecs;
+
+public class HealthInstitution extends SorNode {
+
+ private RecordBuilder builder = new RecordBuilder(SorFullRecordSpecs.HEALTH_INSTITUTION_RECORD_TYPE);
+
+ public HealthInstitution(Attributes attribs, SorNode parent,
+ String parentTag) {
+ super(attribs, parent, parentTag);
+ }
+
+ public boolean parseEndTag(String tagName, String tagValue) throws SAXException {
+ if (SORXmlTagNames.HEALTH_INSTITUTION.equals(tagName)) {
+ return true;
+ }
+ if (SORXmlTagNames.HealthInstitution.SOR_IDENTIFIER.equals(tagName)) {
+ builder.field("sorIdentifier", Long.valueOf(tagValue));
+ } else if (SORXmlTagNames.HealthInstitution.ENTITY_NAME.equals(tagName)) {
+ builder.field("entityName", tagValue);
+ } else if (SORXmlTagNames.HealthInstitution.INSTITUTION_TYPE.equals(tagName)) {
+ builder.field("institutionType", Long.valueOf(tagValue));
+ }
+ return false;
+ }
+
+ @Override
+ public void persistCurrentNode(RecordPersister persister)
+ throws SQLException {
+
+ }
+
+ @Override
+ public void compareAgainstDatabaseAndUpdateDirty(RecordFetcher fetcher)
+ throws SQLException {
+
+ }
-public class HealthInstitution {
- private long sorIdentifier; //required
- private String entityName; //required - String up to 60 chars
- private long institutionType; //required
- private String pharmacyIdentifier; //String up to 20 chars, can be null
- private String shakIdentifier; //String 4-7 characters, can be null
-
- private PostalAddressInformation postalAddressInformation;
- private PostalAddressInformation visitingAddressInformation;
- private VirtualAddressInformation virtualAddressInformation;
-
- private SorStatus sorStatus;//required
-
- private List<Long> replacesEntityCollection; //can be null - contains list of sorIDentifiers
- private List<Long> replacedByEntityCollection; //can be null - contains list of sorIDentifiers
-
- public String getEntityName() {
- return entityName;
- }
-
- public void setEntityName(String entityName) {
- this.entityName = entityName;
- }
-
- public long getInstitutionType() {
- return institutionType;
- }
-
- public void setInstitutionType(long institutionType) {
- this.institutionType = institutionType;
- }
-
- public String getPharmacyIdentifier() {
- return pharmacyIdentifier;
- }
-
- public void setPharmacyIdentifier(String pharmacyIdentifier) {
- this.pharmacyIdentifier = pharmacyIdentifier;
- }
-
- public PostalAddressInformation getPostalAddressInformation() {
- return postalAddressInformation;
- }
-
- public void setPostalAddressInformation(PostalAddressInformation postalAddressInformation) {
- this.postalAddressInformation = postalAddressInformation;
- }
-
- public List<Long> getReplacedByEntityCollection() {
- return replacedByEntityCollection;
- }
-
- public void setReplacedByEntityCollection(List<Long> replacedByEntityCollection) {
- this.replacedByEntityCollection = replacedByEntityCollection;
- }
-
- public List<Long> getReplacesEntityCollection() {
- return replacesEntityCollection;
- }
-
- public void setReplacesEntityCollection(List<Long> replacesEntityCollection) {
- this.replacesEntityCollection = replacesEntityCollection;
- }
-
- public String getShakIdentifier() {
- return shakIdentifier;
- }
-
- public void setShakIdentifier(String shakIdentifier) {
- this.shakIdentifier = shakIdentifier;
- }
-
- public long getSorIdentifier() {
- return sorIdentifier;
- }
-
- public void setSorIdentifier(long sorIdentifier) {
- this.sorIdentifier = sorIdentifier;
- }
-
- public SorStatus getSorStatus() {
- return sorStatus;
- }
-
- public void setSorStatus(SorStatus sorStatus) {
- this.sorStatus = sorStatus;
- }
-
- public VirtualAddressInformation getVirtualAddressInformation() {
- return virtualAddressInformation;
- }
-
- public void setVirtualAddressInformation(VirtualAddressInformation virtualAddressInformation) {
- this.virtualAddressInformation = virtualAddressInformation;
- }
-
- public PostalAddressInformation getVisitingAddressInformation() {
- return visitingAddressInformation;
- }
-
- public void setVisitingAddressInformation(PostalAddressInformation visitingAddressInformation) {
- this.visitingAddressInformation = visitingAddressInformation;
- }
}
@@ -25,89 +25,29 @@
package com.trifork.stamdata.importer.jobs.sor.sor2.xmlmodel;
+import java.sql.SQLException;
-public class InstitutionOwner {
+import org.xml.sax.Attributes;
- private long sorIdentifier;
+import com.trifork.stamdata.persistence.RecordFetcher;
+import com.trifork.stamdata.persistence.RecordPersister;
- private String entityName;
-
- private long ownerType;
- private EanLocationCode eanLocationCode;
+public class InstitutionOwner extends SorNode {
- private PostalAddressInformation postalAddressInformation;
-
- private VirtualAddressInformation virtualAddressInformation;
-
- private SorStatus sorStatus;
-
- public String getEntityName() {
- return entityName;
- }
-
- public void setEntityName(String entityName) {
- this.entityName = entityName;
- }
-
- public long getOwnerType() {
- return ownerType;
- }
-
- public void setOwnerType(long ownerType) {
- this.ownerType = ownerType;
- }
-
- public EanLocationCode getEanLocationCode() {
- return eanLocationCode;
- }
-
- public void setEanLocationCode(EanLocationCode eanLocationCode) {
- this.eanLocationCode = eanLocationCode;
- }
-
- public PostalAddressInformation getPostalAddressInformation() {
- return postalAddressInformation;
- }
-
- public void setPostalAddressInformation(
- PostalAddressInformation postalAddressInformation) {
- this.postalAddressInformation = postalAddressInformation;
- }
-
- public VirtualAddressInformation getVirtualAddressInformation() {
- return virtualAddressInformation;
- }
-
- public void setVirtualAddressInformation(
- VirtualAddressInformation virtualAddressInformation) {
- this.virtualAddressInformation = virtualAddressInformation;
+ public InstitutionOwner(Attributes attribs, SorNode parent, String parentTag) {
+ super(attribs, parent, parentTag);
}
- public SorStatus getSorStatus() {
- return sorStatus;
- }
-
- public void setSorStatus(SorStatus sorStatus) {
- this.sorStatus = sorStatus;
- }
-
- public long getSorIdentifier() {
- return sorIdentifier;
- }
-
- public void setSorIdentifier(long sorIdentifier) {
- this.sorIdentifier = sorIdentifier;
+ @Override
+ public void persistCurrentNode(RecordPersister persister)
+ throws SQLException {
}
@Override
- public String toString() {
- return "InstitutionOwner [sorIdentifier=" + sorIdentifier
- + ", entityName=" + entityName + ", ownerType=" + ownerType
- + ", eanLocationCode=" + eanLocationCode
- + ", postalAddressInformation=" + postalAddressInformation
- + ", virtualAddressInformation=" + virtualAddressInformation
- + ", sorStatus=" + sorStatus + "]";
+ public void compareAgainstDatabaseAndUpdateDirty(RecordFetcher fetcher)
+ throws SQLException {
}
+
}
Oops, something went wrong.

0 comments on commit 7b63c62

Please sign in to comment.