Skip to content

Commit

Permalink
update sample model test
Browse files Browse the repository at this point in the history
better handling of contained references shows that sample model always had a contained reference!
  • Loading branch information
pahjbo committed Feb 15, 2024
1 parent 8448613 commit d55198a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import java.util.Date;
import java.util.List;

import org.ivoa.dm.filter.PhotometricSystem;
import org.ivoa.dm.filter.PhotometryFilter;
import org.ivoa.dm.ivoa.RealQuantity;
import org.ivoa.dm.ivoa.Unit;
import org.ivoa.dm.sample.catalog.inner.SourceCatalogue;
Expand All @@ -33,6 +35,7 @@
public abstract class BaseSourceCatalogueTest extends AbstractTest {

protected SourceCatalogue sc;
protected PhotometricSystem ps;

@org.junit.jupiter.api.BeforeEach
void setUp() {
Expand All @@ -45,7 +48,28 @@ void setUp() {
SDSSSource sdss = new SDSSSource().withPositionError(ellipseError);// UNUSED, but just checking position error subsetting.
sdss.setPositionError(ellipseError);
AlignedEllipse theError = sdss.getPositionError();

final List<PhotometryFilter> filters = List.of(
createPhotometryFilter(fl -> {
fl.bandName ="C-Band";
fl.spectralLocation = new RealQuantity(5.0,GHz);
fl.dataValidityFrom = new Date();
fl.dataValidityTo = new Date();
fl.description = "radio band";
fl.name = fl.bandName;
}),
createPhotometryFilter(fl -> {
fl.bandName ="L-Band";
fl.spectralLocation = new RealQuantity(1.5,GHz);
fl.dataValidityFrom = new Date();
fl.dataValidityTo = new Date();
fl.description = "radio band";
fl.name = fl.bandName;
})
);


ps = new PhotometricSystem("test photometric system", 1, filters);
sc = createSourceCatalogue(c -> {
c.name = "testCat";
c.entry = Arrays.asList(createSDSSSource(s -> {
Expand All @@ -64,26 +88,12 @@ void setUp() {
l.type = LuminosityType.FLUX;
l.value = new RealQuantity(2.5, jansky );
l.error = new RealQuantity(.25, jansky );
l.filter = createPhotometryFilter(fl -> {
fl.bandName ="C-Band";
fl.spectralLocation = new RealQuantity(5.0,GHz);
fl.dataValidityFrom = new Date();
fl.dataValidityTo = new Date();
fl.description = "radio band";
fl.name = fl.bandName;
});
l.filter = filters.get(0);

})
,createLuminosityMeasurement(l ->{
l.description = "lummeas2";
l.filter = createPhotometryFilter(fl -> {
fl.bandName ="L-Band";
fl.spectralLocation = new RealQuantity(1.5,GHz);
fl.dataValidityFrom = new Date();
fl.dataValidityTo = new Date();
fl.description = "radio band";
fl.name = fl.bandName;
});
l.filter = filters.get(1);
l.type = LuminosityType.FLUX;
l.value = new RealQuantity(3.5, jansky );
l.error = new RealQuantity(.25, jansky );//TODO should be allowed to be null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ void sourceCatJaxBTest() throws JAXBException, ParserConfigurationException, Tra

SampleModel model = new SampleModel();
model.addContent(sc);
model.addContent(ps);
model.processReferences();

SampleModel modelin = modelRoundTripXMLwithTest(model);
Expand All @@ -46,7 +47,7 @@ void sourceCatJPATest() {
jakarta.persistence.EntityManager em = setupH2Db(SampleModel.pu_name());
em.getTransaction().begin();
sc.persistRefs(em);
em.persist(sc);
em.persist(sc); // TODO need to test whether Photometric system is saved....
em.getTransaction().commit();
Long id = sc.getId();

Expand Down
7 changes: 3 additions & 4 deletions tools/xslt/jaxb.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,6 @@
</xsl:variable>




<xsl:variable name="hasReferences" select="count($possibleRefs) > 0"/>
<xsl:message>filtered refs=<xsl:value-of select="string-join($references-vodmlref,',')"/> </xsl:message>
<xsl:variable name="ModelClass" select="concat(vf:upperFirst(name),'Model')"/>
Expand Down Expand Up @@ -265,16 +263,17 @@
).collect(
Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
</xsl:if>
<xsl:variable name="contentTypes" as="element()*" select="$models/vo-dml:model[name = $modelsInScope ]//objectType[not(@abstract='true') and (not(vf:referredTo(vf:asvodmlref(.))) or (vf:asvodmlref(.) = vf:referenceTypesInContainmentHierarchy(vf:asvodmlref(.)) ))]"/>
@XmlElements(value = {
<xsl:for-each select="//objectType[not(@abstract='true') and (not(vf:referredTo(vf:asvodmlref(.))) or (vf:asvodmlref(.) = vf:referenceTypesInContainmentHierarchy(vf:asvodmlref(.)) ))]">
<xsl:for-each select="$contentTypes">
@XmlElement(name="<xsl:value-of select="name"/>",
type = <xsl:value-of select="vf:QualifiedJavaType(vf:asvodmlref(.))"/>.class)
<xsl:if test="position() != last()">,</xsl:if>
</xsl:for-each>
})
<xsl:value-of select="$jsontypinfo"/>
private List&lt;Object&gt; content = new ArrayList&lt;&gt;();
<xsl:for-each select="//objectType[not(@abstract='true') and (not(vf:referredTo(vf:asvodmlref(.))) or (vf:asvodmlref(.) = vf:referenceTypesInContainmentHierarchy(vf:asvodmlref(.)) )) ]">
<xsl:for-each select="$contentTypes">
<!-- <xsl:message>ref in hierarchy <xsl:value-of select="vf:asvodmlref(.)"/> refs= <xsl:value-of select="vf:referenceTypesInContainmentHierarchy(vf:asvodmlref(.))"/> </xsl:message>-->
public void addContent( final <xsl:value-of select="vf:QualifiedJavaType(vf:asvodmlref(.))"/> c)
{
Expand Down

0 comments on commit d55198a

Please sign in to comment.