use of alma.entities.commonentity.EntityRefT in project ACS by ACS-Community.
the class EntityRefFinder method findEntityReferences.
public EntityRefT[] findEntityReferences(Object rootEntityObject) throws EntityException {
ArrayList<EntityRefT> entityRefs = new ArrayList<EntityRefT>();
StopWatch stopw = new StopWatch(null);
recursiveFindEntityReferences(rootEntityObject, entityRefs);
if (m_debug) {
System.out.println("findEntityReferences took " + stopw.getLapTimeMillis() + " ms.");
}
return (entityRefs.toArray(new EntityRefT[0]));
}
use of alma.entities.commonentity.EntityRefT in project ACS by ACS-Community.
the class TestEntityFactory method getReferencesInObsProject.
// SchedBlock[] getSchedblocks()
// {
// ArrayList schedBlockList = new ArrayList();
//
// SchedBlock sb1 = new SchedBlock();
// schedBlockList.add(sb1);
//
// SchedBlockEntityT entity = new SchedBlockEntityT();
// sb1.setSchedBlockEntity(entity);
//
// entity.setEntityId("uid://X1230000000000000/X00000003");
//
// ObsProjectRefT ref = new ObsProjectRefT();
// ref.setEntityId("uid://X1230000000000000/X00000001");
// sb1.setObsProjectRef(ref);
//
// return (SchedBlock[]) schedBlockList.toArray(new SchedBlock[0]);
// }
//
/**
* Returns (hardcoded) the EntityRef objects that are part of the ObsProject
* that can be retrieved from {@link #getObsProject}.
* Needed to test the code that dynamically finds these objects.
* @return EntityRefT[]
*/
EntityRefT[] getReferencesInObsProject(ObsProject proj) {
ArrayList<EntityRefT> entityRefs = new ArrayList<EntityRefT>();
EntityRefT propRef = proj.getObsProposalRef();
entityRefs.add(propRef);
EntityRefT sb1Ref = proj.getObsProgram().getObsPlan().getObsUnitSetTChoice().getSchedBlockRef()[0];
entityRefs.add(sb1Ref);
return entityRefs.toArray(new EntityRefT[0]);
}
use of alma.entities.commonentity.EntityRefT in project ACS by ACS-Community.
the class EntityRefFinderTest method testObsProject.
public void testObsProject() throws Throwable {
ObsProject proj = m_entityFactory.getObsProject();
EntityRefT[] refs = m_entityRefFinder.findEntityReferences(proj);
assertNotNull(refs);
EntityRefT[] knownRefs = m_entityFactory.getReferencesInObsProject(proj);
assertTrue("correct number of entity references", (refs.length == knownRefs.length));
for (int i = 0; i < refs.length; i++) {
assertNotNull("ref not null", refs[i]);
assertTrue(refs[i] == knownRefs[i]);
}
// for manual inspection of output
if (refs.length > 0 && (refs[0] instanceof ObsProposalRefT)) {
StringWriter writer = new StringWriter();
refs[0].marshal(writer);
String serializedObsProposalRef = writer.toString();
System.out.println("serialized ObsProposalRefT object:");
System.out.println(serializedObsProposalRef);
ObsProposalRefT recreatedRef = ObsProposalRefT.unmarshalObsProposalRefT(new StringReader(serializedObsProposalRef));
writer = new StringWriter();
System.out.println("recreated and reserialized ObsProposalRefT:");
recreatedRef.marshal(writer);
String reserializedObsProposalRef = writer.toString();
System.out.println(reserializedObsProposalRef);
}
// assertTrue("reference to ObsProject", refs[0] instanceof ObsProjectRefT);
// String projId = ((ObsProjectRefT) refs[0]).getEntityId();
// assertEquals("correct id", "dummyObsProjectId", projId);
}
use of alma.entities.commonentity.EntityRefT in project ACS by ACS-Community.
the class EntityRefFinderTest method testObsProposal.
public void testObsProposal() throws Throwable {
ObsProposal prop = m_entityFactory.getObsProposal();
EntityRefT[] refs = m_entityRefFinder.findEntityReferences(prop);
assertNotNull(refs);
// assertTrue("one entity reference", (refs.length == 1 && refs[0] != null) );
// assertTrue("reference to ObsProject", refs[0] instanceof ObsProjectRefT);
// String projId = ((ObsProjectRefT) refs[0]).getEntityId();
// assertEquals("correct id", "dummyObsProjectId", projId);
}
Aggregations