X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.app.core%2Fsrc%2Forg%2Fargeo%2Fapp%2Fcore%2FSuiteMaintenance.java;fp=org.argeo.app.core%2Fsrc%2Forg%2Fargeo%2Fapp%2Fcore%2FSuiteMaintenance.java;h=2104145c648d5ec2d812e4df66358b889fa70eb6;hb=d6c9d33b61e475914d3f8d7534374ed30eca8150;hp=0000000000000000000000000000000000000000;hpb=618968cf9d259ccded45a9455a26c516dbfe828f;p=gpl%2Fargeo-suite.git diff --git a/org.argeo.app.core/src/org/argeo/app/core/SuiteMaintenance.java b/org.argeo.app.core/src/org/argeo/app/core/SuiteMaintenance.java new file mode 100644 index 0000000..2104145 --- /dev/null +++ b/org.argeo.app.core/src/org/argeo/app/core/SuiteMaintenance.java @@ -0,0 +1,70 @@ +package org.argeo.app.core; + +import java.net.MalformedURLException; +import java.net.URL; + +import javax.measure.Quantity; +import javax.measure.quantity.Area; + +import org.argeo.api.acr.spi.ContentNamespace; +import org.argeo.api.acr.spi.ProvidedRepository; +import org.geotools.gml3.v3_2.GML; + +import si.uom.SI; +import tech.units.indriya.quantity.Quantities; + +/** + * Background service starting and stopping with the whole system, and making + * sure it is in a proper state. + */ +public class SuiteMaintenance { + private ProvidedRepository contentRepository; + + public void start() { + // make sure that the unit system is initialised + Quantity dummy = Quantities.getQuantity(0, SI.SQUARE_METRE); + + getContentRepository().registerTypes(SuiteContentNamespace.values()); +// for (SuiteContentTypes types : SuiteContentTypes.values()) { +// getContentRepository().registerTypes(types.getDefaultPrefix(), types.getNamespace(), +// types.getResource() != null ? types.getResource().toExternalForm() : null); +// } + + // GML schema import fails because of xlinks issues + getContentRepository().registerTypes(new ContentNamespace() { + + @Override + public URL getSchemaResource() { + try { + return new URL(GML.getInstance().getSchemaLocation()); + } catch (MalformedURLException e) { + throw new IllegalArgumentException(e); + } + } + + @Override + public String getNamespaceURI() { + return GML.getInstance().getNamespaceURI(); + } + + @Override + public String getDefaultPrefix() { + return "gml"; + } + }); + + } + + public void stop() { + + } + + protected ProvidedRepository getContentRepository() { + return contentRepository; + } + + public void setContentRepository(ProvidedRepository contentRepository) { + this.contentRepository = contentRepository; + } + +}