Search in sources :

Example 1 with EntityRefT

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]));
}
Also used : ArrayList(java.util.ArrayList) EntityRefT(alma.entities.commonentity.EntityRefT) StopWatch(alma.acs.util.StopWatch)

Example 2 with EntityRefT

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]);
}
Also used : ArrayList(java.util.ArrayList) EntityRefT(alma.entities.commonentity.EntityRefT)

Example 3 with EntityRefT

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);
}
Also used : StringWriter(java.io.StringWriter) ObsProject(alma.xmljbind.test.obsproject.ObsProject) StringReader(java.io.StringReader) ObsProposalRefT(alma.xmljbind.test.obsproposal.ObsProposalRefT) EntityRefT(alma.entities.commonentity.EntityRefT)

Example 4 with EntityRefT

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);
}
Also used : ObsProposal(alma.xmljbind.test.obsproposal.ObsProposal) EntityRefT(alma.entities.commonentity.EntityRefT)

Aggregations

EntityRefT (alma.entities.commonentity.EntityRefT)4 ArrayList (java.util.ArrayList)2 StopWatch (alma.acs.util.StopWatch)1 ObsProject (alma.xmljbind.test.obsproject.ObsProject)1 ObsProposal (alma.xmljbind.test.obsproposal.ObsProposal)1 ObsProposalRefT (alma.xmljbind.test.obsproposal.ObsProposalRefT)1 StringReader (java.io.StringReader)1 StringWriter (java.io.StringWriter)1