Skip to content

Commit

Permalink
Added relationships for CA CI XH HA HG
Browse files Browse the repository at this point in the history
  • Loading branch information
slh17006 committed Mar 27, 2020
1 parent 3d84cde commit fd4f4e4
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ class CA implements GeiaEntity {
@XmlElement(name = "preventive_maintenance_checks_and_services_indicator_code")
String preventiveMaintenanceChecksAndServicesIndicatorCode

transient List<CI> ciChildren = new ArrayList<>()

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ class CI implements GeiaEntity {
@XmlElement(name = "task_provision_logistics_support_analysis_control_number_type")
String taskProvisionLcnType

transient List<HG> hgChildren = new ArrayList<>()
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ class XH implements GeiaEntity {
@XmlElement(name = "commercial_and_government_entity_state")
String cageState

transient List<HA> haChildren = new ArrayList<>()

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@
import com.lmco.spectrum.systemnavigation3d.domain.dto.CA;
import com.lmco.spectrum.systemnavigation3d.domain.dto.XA;
import com.lmco.spectrum.systemnavigation3d.domain.dto.XB;
import com.lmco.spectrum.systemnavigation3d.domain.dto.XH;
import com.lmco.spectrum.systemnavigation3d.domain.dto.CI;
import com.lmco.spectrum.systemnavigation3d.domain.dto.HG;

import java.util.List;

public interface GeiaDataSource {

List<XA> getXAs();
List<XH> getXHs();
XA getXA(String endItemAcronymCode);
XH getXH(String cageCode);
XB getXB(XA src, String lcn);
CA getCA(XB src, String taskCode);
CI getCI(CA src, String taskProvisionReferenceNumber);
HG getHG(CI src, String referenceNumber);

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ public class XMLGeiaDataSource implements GeiaDataSource {
private Map<Class<? extends GeiaEntity>, List<GeiaEntity>> geiaEntityMap;

private List<XA> xaList;
private List<XH> xhList;

public XMLGeiaDataSource(InputStream xmlStream) {
this.xaList = new ArrayList<>();
this.xhList = new ArrayList<>();
this.geiaEntityMap = new HashMap<>();

try {
Expand Down Expand Up @@ -49,11 +51,15 @@ private void processGeiaStd() {
}

xaList.addAll(getEntities(XA.class));
xhList.addAll(getEntities(XH.class));

for(XA xa : xaList) {
pairXAWithChildren(xa);
}

for(XH xh : xhList){
pairXHWithChildren(xh);
}
}

private void pairXAWithChildren(XA src) {
Expand All @@ -66,6 +72,13 @@ private void pairXAWithChildren(XA src) {
});
}

private void pairXHWithChildren(XH src){
getEntities(HA.class)
.stream()
.filter(ha -> ha.getCageCode() == src.getCageCode())
.forEach(ha -> src.getHaChildren().add(ha));
}

private void pairXBWithChildren(XB src) {
getEntities(XB.class)
.stream()
Expand All @@ -77,19 +90,47 @@ private void pairXBWithChildren(XB src) {
getEntities(CA.class)
.stream()
.filter(ca -> src.getLcn().equals(ca.getLcn()))
.forEach(ca -> src.getCaChildren().add(ca)); // TODO process CA children
.forEach(ca -> {
pairCAWithChildren(ca);
src.getCaChildren().add(ca);
});
}

private void pairCAWithChildren(CA src){
getEntities(CI.class)
.stream()
.filter(ci -> src.getLcn().equals(ci.getLcn()))
.forEach(ci -> {
pairCIWithChildren(ci);
src.getCiChildren().add(ci);
});
}

private void pairCIWithChildren(CI src){
getEntities(HG.class)
.stream()
.filter(hg -> src.getLcn().equals(hg.getLcn()))
.forEach((hg -> src.getHgChildren().add(hg)));
}

@Override
public List<XA> getXAs() {
return xaList;
}

@Override
public List<XH> getXHs() {return xhList;}

@Override
public XA getXA(String endItemAcronymCode) {
return xaList.stream().filter(xa -> xa.getEndItemAcronymCode().equals(endItemAcronymCode)).findFirst().orElse(null);
}

@Override
public XH getXH(String cageCode){
return xhList.stream().filter(xh -> xh.getCageCode().equals(cageCode)).findFirst().orElse(null);
}

@Override
public XB getXB(XA src, String lcn) {
return src.getXbChildren().stream().filter(xb -> xb.getLcn().equals(lcn)).findFirst().orElse(null);
Expand All @@ -99,4 +140,15 @@ public XB getXB(XA src, String lcn) {
public CA getCA(XB src, String taskCode) {
return src.getCaChildren().stream().filter(ca -> ca.getTaskCode().equals(taskCode)).findFirst().orElse(null);
}

@Override
public CI getCI(CA src, String taskProvisionReferenceNumber){
return src.getCiChildren().stream().filter(ci -> ci.getTaskProvisionReferenceNumber().equals(taskProvisionReferenceNumber)).findFirst().orElse(null);
}

@Override
public HG getHG(CI src, String referenceNumber)
{
return src.getHgChildren().stream().filter(hg -> hg.getReferenceNumber().equals(referenceNumber)).findFirst().orElse(null);
}
}

0 comments on commit fd4f4e4

Please sign in to comment.