Maintenance

This commit is contained in:
Fabio Sinibaldi 2020-09-03 16:29:36 +02:00
parent d8ab337a46
commit 5dc93e341f
12 changed files with 1142 additions and 131 deletions

5
CHANGELOG.md Normal file
View File

@ -0,0 +1,5 @@
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
# Changelog for "geoportal-logic"

26
FUNDING.md Normal file
View File

@ -0,0 +1,26 @@
# Acknowledgments
The projects leading to this software have received funding from a series of European Union programmes including:
- the Sixth Framework Programme for Research and Technological Development
- [DILIGENT](https://cordis.europa.eu/project/id/004260) (grant no. 004260).
- the Seventh Framework Programme for research, technological development and demonstration
- [D4Science](https://cordis.europa.eu/project/id/212488) (grant no. 212488);
- [D4Science-II](https://cordis.europa.eu/project/id/239019) (grant no.239019);
- [ENVRI](https://cordis.europa.eu/project/id/283465) (grant no. 283465);
- [iMarine](https://cordis.europa.eu/project/id/283644) (grant no. 283644);
- [EUBrazilOpenBio](https://cordis.europa.eu/project/id/288754) (grant no. 288754).
- the H2020 research and innovation programme
- [SoBigData](https://cordis.europa.eu/project/id/654024) (grant no. 654024);
- [PARTHENOS](https://cordis.europa.eu/project/id/654119) (grant no. 654119);
- [EGI-Engage](https://cordis.europa.eu/project/id/654142) (grant no. 654142);
- [ENVRI PLUS](https://cordis.europa.eu/project/id/654182) (grant no. 654182);
- [BlueBRIDGE](https://cordis.europa.eu/project/id/675680) (grant no. 675680);
- [PerformFISH](https://cordis.europa.eu/project/id/727610) (grant no. 727610);
- [AGINFRA PLUS](https://cordis.europa.eu/project/id/731001) (grant no. 731001);
- [DESIRA](https://cordis.europa.eu/project/id/818194) (grant no. 818194);
- [ARIADNEplus](https://cordis.europa.eu/project/id/823914) (grant no. 823914);
- [RISIS 2](https://cordis.europa.eu/project/id/824091) (grant no. 824091);
- [EOSC-Pillar](https://cordis.europa.eu/project/id/857650) (grant no. 857650);
- [Blue Cloud](https://cordis.europa.eu/project/id/862409) (grant no. 862409);
- [SoBigData-PlusPlus](https://cordis.europa.eu/project/id/871042) (grant no. 871042);

312
LICENSE.md Normal file
View File

@ -0,0 +1,312 @@
# European Union Public Licence V. 1.1
EUPL © the European Community 2007
This European Union Public Licence (the “EUPL”) applies to the Work or Software
(as defined below) which is provided under the terms of this Licence. Any use of
the Work, other than as authorised under this Licence is prohibited (to the
extent such use is covered by a right of the copyright holder of the Work).
The Original Work is provided under the terms of this Licence when the Licensor
(as defined below) has placed the following notice immediately following the
copyright notice for the Original Work:
Licensed under the EUPL V.1.1
or has expressed by any other mean his willingness to license under the EUPL.
## 1. Definitions
In this Licence, the following terms have the following meaning:
- The Licence: this Licence.
- The Original Work or the Software: the software distributed and/or
communicated by the Licensor under this Licence, available as Source Code and
also as Executable Code as the case may be.
- Derivative Works: the works or software that could be created by the Licensee,
based upon the Original Work or modifications thereof. This Licence does not
define the extent of modification or dependence on the Original Work required
in order to classify a work as a Derivative Work; this extent is determined by
copyright law applicable in the country mentioned in Article 15.
- The Work: the Original Work and/or its Derivative Works.
- The Source Code: the human-readable form of the Work which is the most
convenient for people to study and modify.
- The Executable Code: any code which has generally been compiled and which is
meant to be interpreted by a computer as a program.
- The Licensor: the natural or legal person that distributes and/or communicates
the Work under the Licence.
- Contributor(s): any natural or legal person who modifies the Work under the
Licence, or otherwise contributes to the creation of a Derivative Work.
- The Licensee or “You”: any natural or legal person who makes any usage of the
Software under the terms of the Licence.
- Distribution and/or Communication: any act of selling, giving, lending,
renting, distributing, communicating, transmitting, or otherwise making
available, on-line or off-line, copies of the Work or providing access to its
essential functionalities at the disposal of any other natural or legal
person.
## 2. Scope of the rights granted by the Licence
The Licensor hereby grants You a world-wide, royalty-free, non-exclusive,
sub-licensable licence to do the following, for the duration of copyright vested
in the Original Work:
- use the Work in any circumstance and for all usage, reproduce the Work, modify
- the Original Work, and make Derivative Works based upon the Work, communicate
- to the public, including the right to make available or display the Work or
- copies thereof to the public and perform publicly, as the case may be, the
- Work, distribute the Work or copies thereof, lend and rent the Work or copies
- thereof, sub-license rights in the Work or copies thereof.
Those rights can be exercised on any media, supports and formats, whether now
known or later invented, as far as the applicable law permits so.
In the countries where moral rights apply, the Licensor waives his right to
exercise his moral right to the extent allowed by law in order to make effective
the licence of the economic rights here above listed.
The Licensor grants to the Licensee royalty-free, non exclusive usage rights to
any patents held by the Licensor, to the extent necessary to make use of the
rights granted on the Work under this Licence.
## 3. Communication of the Source Code
The Licensor may provide the Work either in its Source Code form, or as
Executable Code. If the Work is provided as Executable Code, the Licensor
provides in addition a machine-readable copy of the Source Code of the Work
along with each copy of the Work that the Licensor distributes or indicates, in
a notice following the copyright notice attached to the Work, a repository where
the Source Code is easily and freely accessible for as long as the Licensor
continues to distribute and/or communicate the Work.
## 4. Limitations on copyright
Nothing in this Licence is intended to deprive the Licensee of the benefits from
any exception or limitation to the exclusive rights of the rights owners in the
Original Work or Software, of the exhaustion of those rights or of other
applicable limitations thereto.
## 5. Obligations of the Licensee
The grant of the rights mentioned above is subject to some restrictions and
obligations imposed on the Licensee. Those obligations are the following:
Attribution right: the Licensee shall keep intact all copyright, patent or
trademarks notices and all notices that refer to the Licence and to the
disclaimer of warranties. The Licensee must include a copy of such notices and a
copy of the Licence with every copy of the Work he/she distributes and/or
communicates. The Licensee must cause any Derivative Work to carry prominent
notices stating that the Work has been modified and the date of modification.
Copyleft clause: If the Licensee distributes and/or communicates copies of the
Original Works or Derivative Works based upon the Original Work, this
Distribution and/or Communication will be done under the terms of this Licence
or of a later version of this Licence unless the Original Work is expressly
distributed only under this version of the Licence. The Licensee (becoming
Licensor) cannot offer or impose any additional terms or conditions on the Work
or Derivative Work that alter or restrict the terms of the Licence.
Compatibility clause: If the Licensee Distributes and/or Communicates Derivative
Works or copies thereof based upon both the Original Work and another work
licensed under a Compatible Licence, this Distribution and/or Communication can
be done under the terms of this Compatible Licence. For the sake of this clause,
“Compatible Licence” refers to the licences listed in the appendix attached to
this Licence. Should the Licensees obligations under the Compatible Licence
conflict with his/her obligations under this Licence, the obligations of the
Compatible Licence shall prevail.
Provision of Source Code: When distributing and/or communicating copies of the
Work, the Licensee will provide a machine-readable copy of the Source Code or
indicate a repository where this Source will be easily and freely available for
as long as the Licensee continues to distribute and/or communicate the Work.
Legal Protection: This Licence does not grant permission to use the trade names,
trademarks, service marks, or names of the Licensor, except as required for
reasonable and customary use in describing the origin of the Work and
reproducing the content of the copyright notice.
## 6. Chain of Authorship
The original Licensor warrants that the copyright in the Original Work granted
hereunder is owned by him/her or licensed to him/her and that he/she has the
power and authority to grant the Licence.
Each Contributor warrants that the copyright in the modifications he/she brings
to the Work are owned by him/her or licensed to him/her and that he/she has the
power and authority to grant the Licence.
Each time You accept the Licence, the original Licensor and subsequent
Contributors grant You a licence to their contributions to the Work, under the
terms of this Licence.
## 7. Disclaimer of Warranty
The Work is a work in progress, which is continuously improved by numerous
contributors. It is not a finished work and may therefore contain defects or
“bugs” inherent to this type of software development.
For the above reason, the Work is provided under the Licence on an “as is” basis
and without warranties of any kind concerning the Work, including without
limitation merchantability, fitness for a particular purpose, absence of defects
or errors, accuracy, non-infringement of intellectual property rights other than
copyright as stated in Article 6 of this Licence.
This disclaimer of warranty is an essential part of the Licence and a condition
for the grant of any rights to the Work.
## 8. Disclaimer of Liability
Except in the cases of wilful misconduct or damages directly caused to natural
persons, the Licensor will in no event be liable for any direct or indirect,
material or moral, damages of any kind, arising out of the Licence or of the use
of the Work, including without limitation, damages for loss of goodwill, work
stoppage, computer failure or malfunction, loss of data or any commercial
damage, even if the Licensor has been advised of the possibility of such
damage. However, the Licensor will be liable under statutory product liability
laws as far such laws apply to the Work.
## 9. Additional agreements
While distributing the Original Work or Derivative Works, You may choose to
conclude an additional agreement to offer, and charge a fee for, acceptance of
support, warranty, indemnity, or other liability obligations and/or services
consistent with this Licence. However, in accepting such obligations, You may
act only on your own behalf and on your sole responsibility, not on behalf of
the original Licensor or any other Contributor, and only if You agree to
indemnify, defend, and hold each Contributor harmless for any liability incurred
by, or claims asserted against such Contributor by the fact You have accepted
any such warranty or additional liability.
## 10. Acceptance of the Licence
The provisions of this Licence can be accepted by clicking on an icon “I agree”
placed under the bottom of a window displaying the text of this Licence or by
affirming consent in any other similar way, in accordance with the rules of
applicable law. Clicking on that icon indicates your clear and irrevocable
acceptance of this Licence and all of its terms and conditions.
Similarly, you irrevocably accept this Licence and all of its terms and
conditions by exercising any rights granted to You by Article 2 of this Licence,
such as the use of the Work, the creation by You of a Derivative Work or the
Distribution and/or Communication by You of the Work or copies thereof.
## 11. Information to the public
In case of any Distribution and/or Communication of the Work by means of
electronic communication by You (for example, by offering to download the Work
from a remote location) the distribution channel or media (for example, a
website) must at least provide to the public the information requested by the
applicable law regarding the Licensor, the Licence and the way it may be
accessible, concluded, stored and reproduced by the Licensee.
## 12. Termination of the Licence
The Licence and the rights granted hereunder will terminate automatically upon
any breach by the Licensee of the terms of the Licence.
Such a termination will not terminate the licences of any person who has
received the Work from the Licensee under the Licence, provided such persons
remain in full compliance with the Licence.
## 13. Miscellaneous
Without prejudice of Article 9 above, the Licence represents the complete
agreement between the Parties as to the Work licensed hereunder.
If any provision of the Licence is invalid or unenforceable under applicable
law, this will not affect the validity or enforceability of the Licence as a
whole. Such provision will be construed and/or reformed so as necessary to make
it valid and enforceable.
The European Commission may publish other linguistic versions and/or new
versions of this Licence, so far this is required and reasonable, without
reducing the scope of the rights granted by the Licence. New versions of the
Licence will be published with a unique version number.
All linguistic versions of this Licence, approved by the European Commission,
have identical value. Parties can take advantage of the linguistic version of
their choice.
## 14. Jurisdiction
Any litigation resulting from the interpretation of this License, arising
between the European Commission, as a Licensor, and any Licensee, will be
subject to the jurisdiction of the Court of Justice of the European Communities,
as laid down in article 238 of the Treaty establishing the European Community.
Any litigation arising between Parties, other than the European Commission, and
resulting from the interpretation of this License, will be subject to the
exclusive jurisdiction of the competent court where the Licensor resides or
conducts its primary business.
## 15. Applicable Law
This Licence shall be governed by the law of the European Union country where
the Licensor resides or has his registered office.
This licence shall be governed by the Belgian law if:
- a litigation arises between the European Commission, as a Licensor, and any
- Licensee; the Licensor, other than the European Commission, has no residence
- or registered office inside a European Union country.
## Appendix
“Compatible Licences” according to article 5 EUPL are:
- GNU General Public License (GNU GPL) v. 2
- Open Software License (OSL) v. 2.1, v. 3.0
- Common Public License v. 1.0
- Eclipse Public License v. 1.0
- Cecill v. 2.0

View File

@ -9,6 +9,7 @@ import java.sql.SQLException;
import org.gcube.application.geoportal.model.DataParsingException;
import org.gcube.application.geoportal.model.DatabaseConnection;
import org.gcube.application.geoportal.model.MOSI;
import org.gcube.application.geoportal.model.PostgisTable;
import lombok.extern.slf4j.Slf4j;
@ -44,27 +45,6 @@ public class PostgisDBManager implements PostgisDBManagerI {
throw new RuntimeException(e);
}
// log.info("Initializing Database..");
//
// Connection conn=null;
//
//
// conn=DriverManager.getConnection(config.getUrl(),config.getUser(),config.getPwd());
// conn.setAutoCommit(config.getAutocommit());
// File sqlFolder=Files.getFileFromResources("sql");
//
// if(!sqlFolder.isDirectory()) throw new RuntimeException(sqlFolder.getAbsolutePath()+" is not a folder.");
// Statement stmt=conn.createStatement();
// for(File f:sqlFolder.listFiles()) {
// log.info("Executing "+f.getName());
// String sql=Files.readFileAsString(f.getAbsolutePath(),Charset.forName("UTF-8"));
//
// stmt.execute(sql);
// }
//
// log.info("Committing..");
// conn.commit();
}
@ -153,22 +133,9 @@ public class PostgisDBManager implements PostgisDBManagerI {
conn.createStatement().executeUpdate("TRUNCATE Table "+tableName);
}
// private static final void printRs(ResultSet rs) throws SQLException {
// System.out.println("****************************");
// ResultSetMetaData meta=rs.getMetaData();
// for(int i=1; i<meta.getColumnCount();i++) {
// System.out.print(meta.getCatalogName(i));
// }
// System.out.println();
// while(rs.next()) {
// for(int i=1; i<meta.getColumnCount();i++) {
// Object obj=rs.getObject(i);
// if(obj==null) System.out.print("NULL OBJECT");
// else System.out.print(obj);
// }
// System.out.println();
// }
// System.out.println("***********************");
// }
@Override
public ResultSet queryAll(PostgisTable table) throws SQLException {
// TODO Check schema
return conn.createStatement().executeQuery("Select * from "+table.getTablename());
}
}

View File

@ -1,9 +1,9 @@
package org.gcube.application.geoportal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.gcube.application.geoportal.model.CentroidRecord;
import org.gcube.application.geoportal.model.DataParsingException;
import org.gcube.application.geoportal.model.PostgisTable;
import org.gcube.application.geoportal.model.PostgisTable.POINT;
@ -29,4 +29,6 @@ public interface PostgisDBManagerI {
POINT evaluateCentroid(PostgisTable table) throws SQLException, DataParsingException;
ResultSet queryAll(PostgisTable table) throws SQLException;
}

View File

@ -1,25 +1,40 @@
package org.gcube.application.geoportal.model;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.j256.ormlite.field.DatabaseField;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.experimental.NonFinal;
@Data
@AllArgsConstructor
public class MOSI {
public static final HashMap<String,String> FIELDS_DESCRIPTION=new HashMap<String,String>();
static {
//CD
FIELDS_DESCRIPTION.put("TSK", "Tipo modulo");
FIELDS_DESCRIPTION.put("CDM", "Tipo modulo");
FIELDS_DESCRIPTION.put("ESC", "Tipo modulo");
FIELDS_DESCRIPTION.put("ECP", "Tipo modulo");
FIELDS_DESCRIPTION.put("CBC", "Tipo modulo");
FIELDS_DESCRIPTION.put("TSK", "Tipo modulo");
FIELDS_DESCRIPTION.put("TSK", "Tipo modulo");
FIELDS_DESCRIPTION.put("TSK", "Tipo modulo");
FIELDS_DESCRIPTION.put("TSK", "Tipo modulo");
}
// IDENTIFICAZIONE
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class CD_Type{
@Data
@AllArgsConstructor
public static class ACC_Type{
//Ente/Soggetto Responsabile
@NonNull
@ -52,12 +67,14 @@ public class MOSI {
//ALTRO CODICE
@NonNull
private List<ACC_Type> ACC;
private Collection<ACC_Type> ACC;
}
// AREA/SITO
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class OG_Type{
//Ambito di tutela MiBACT
@NonNull
@ -75,14 +92,17 @@ public class MOSI {
private String OGT;
//Denominazione
private List<String> OGN;
private Collection<String> OGN;
}
//LOCALIZZAZIONE
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class LC_Type{
@Data
@AllArgsConstructor
public static class ACB_Type{
//Accessibilità
private String ACBA;
@ -106,7 +126,7 @@ public class MOSI {
//Indirizzo
private String LCI;
//Toponimo
private List<String> PVL;
private Collection<String> PVL;
//Tipo di contesto
private String PVZ;
@ -117,6 +137,8 @@ public class MOSI {
//CRONOLOGIA
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class DT_Type{
//Riferimento Cronologico
@NonNull
@ -128,6 +150,8 @@ public class MOSI {
//DATI ANALITICI
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class DA_Type{
//Descrizione
@NonNull
@ -135,15 +159,18 @@ public class MOSI {
//Modalità di individuazione
@NonNull
private List<String> OGM;
private Collection<String> OGM;
}
//GEOREFERENZIAZIONE
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class GE_Type{
//COORDINATE
@Data
@AllArgsConstructor
public static class GEC_Type{
@NonNull
private String GECX;
@ -152,6 +179,8 @@ public class MOSI {
}
//BASE CARTOGRAFICA
@Data
@AllArgsConstructor
public static class GPB_Type{
//Descrizione Sintetica
@NonNull
@ -173,7 +202,7 @@ public class MOSI {
//COORDINATE
@NonNull
private List<GEC_Type> GEC;
private Collection<GEC_Type> GEC;
//Tecnica di georeferenziazione
@NonNull
@ -188,10 +217,13 @@ public class MOSI {
// CONDIZIONE GIURIDICA E PROVVEDIMENTI DI TUTELA
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class TU_Type{
//CONDIZIONE GIURIDICA
@Data
@AllArgsConstructor
public static class CDG_Type{
//Indicazione generica
@NonNull
@ -200,6 +232,7 @@ public class MOSI {
// PROVVEDIMENTI DI TUTELA
@Data
@AllArgsConstructor
public static class NVC_Type{
//Normativa di riferimento
private String NVCT;
@ -215,6 +248,7 @@ public class MOSI {
//STRUMENTI URBANISTICO - TERRITORIALI
@Data
@AllArgsConstructor
public static class STU_Type{
//Ente/Amministrazione
private String STUE;
@ -233,19 +267,22 @@ public class MOSI {
private String BPT;
//PROVVEDIMENTI DI TUTELA
private List<NVC_Type> NVC;
private Collection<NVC_Type> NVC;
// STRUMENTI URBANISTICO - TERRITORIALI
private List<STU_Type> STU;
private Collection<STU_Type> STU;
}
// INDAGINI
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class RE_Type{
//RICOGNIZIONE ARCHEOLOGICA
@Data
@AllArgsConstructor
public static class RCG_Type{
//Denominazione Ricognizione
@NonNull
@ -263,6 +300,7 @@ public class MOSI {
// PRESENZA MATERIALI
@Data
@AllArgsConstructor
public static class MTP_Type{
//Categoria materiale
@NonNull
@ -273,6 +311,7 @@ public class MOSI {
//FOTOINTERPRETAIONE / FOTORESTITUZIONE
@Data
@AllArgsConstructor
public static class FOI_Type{
//Tipo immagine
private String FOIT;
@ -295,21 +334,24 @@ public class MOSI {
private RCG_Type RCG;
@NonNull
private List<MTP_Type> MTP;
private Collection<MTP_Type> MTP;
//Assenza di materiali
@NonNull
private String MTZ;
private List<FOI_Type> FOI;
private Collection<FOI_Type> FOI;
}
// INDAGINI PREGRESSE
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class IP_Type{
//INDAGINI ARCHEOLOGICHE PREGRESSE
@Data
@AllArgsConstructor
public static class IAP_Type{
//Denominazione indagine
@NonNull
@ -326,15 +368,18 @@ public class MOSI {
private String IAPS;
}
private List<IAP_Type> IAP;
private Collection<IAP_Type> IAP;
}
// DATI TECNICI
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class MT_Type{
//MISURE
@Data
@AllArgsConstructor
public static class MIS_Type{
//Tipo Misura
private String MISZ;
@ -346,6 +391,7 @@ public class MOSI {
//ALTIMETRIA / QUOTE
@Data
@AllArgsConstructor
public static class MTA_Type{
//Riferimento
private String MTAP;
@ -362,15 +408,18 @@ public class MOSI {
private MIS_Type MIS;
private List<MTA_Type> MTA;
private Collection<MTA_Type> MTA;
}
//Valutazione / INTERPRETAZIONE
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class VR_Type{
//VALUTAZIONE POTENZIALE ARCHEOLOGICO
@Data
@AllArgsConstructor
public static class VRP_Type{
//Interpretazione
@NonNull
@ -390,6 +439,7 @@ public class MOSI {
//VALUTAZIONE RISCHIO ARCHEOLOGICO
@Data
@AllArgsConstructor
public static class VRR_Type{
//Codice progetto di riferimento
@NonNull
@ -415,9 +465,12 @@ public class MOSI {
// DOCUMENTAZIONE
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class DO_Type{
//DOCUMENTAZIONE FOTOGRAFICA
@Data
@AllArgsConstructor
public static class FTA_Type{
//Codice identificativo
private String FTAN;
@ -435,6 +488,7 @@ public class MOSI {
}
//DOCUMENTAZIONE GRAFICA E CARTOGRAFICA
@Data
@AllArgsConstructor
public static class DRA_Type{
//Codice identificativo
private String DRAN;
@ -452,6 +506,7 @@ public class MOSI {
//FONTI E DOCUMENTI
@Data
@AllArgsConstructor
public static class FNT_Type{
//Codice identificativo
private String FNTI;
@ -469,6 +524,7 @@ public class MOSI {
//BIBLIOGRAFIA
@Data
@AllArgsConstructor
public static class BIB_Type{
//Abbreviazione
private String BIBR;
@ -483,25 +539,27 @@ public class MOSI {
}
@NonNull
private List<FTA_Type> FTA;
private List<DRA_Type> DRA;
private List<FNT_Type> FNT;
private List<BIB_Type> BIB;
private Collection<FTA_Type> FTA;
private Collection<DRA_Type> DRA;
private Collection<FNT_Type> FNT;
private Collection<BIB_Type> BIB;
}
// CERTIFICAZIONE E GESTIONE DATI
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class CM_Type{
//Funzionario responsabile
@NonNull
private List<String> FUR;
private Collection<String> FUR;
//Responsabile contenuti
@NonNull
private List<String> CMR;
private Collection<String> CMR;
//Responsabile redazione modulo
@NonNull
private List <String> CMC;
private Collection <String> CMC;
//Anno di redazione
@NonNull
private String CMA;
@ -510,6 +568,19 @@ public class MOSI {
private String ADP;
}
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class Extent_Type{
@NonNull
private Double west;
@NonNull
private Double est;
@NonNull
private Double north;
@NonNull
private Double south;
}
@NonNull
private CD_Type CD;
@ -545,4 +616,13 @@ public class MOSI {
@NonNull
private CM_Type CM;
@NonNull
// TO BE COMPUTED
private Extent_Type extent;
}

View File

@ -352,4 +352,7 @@ public class PostgisTable {
return fieldName.toLowerCase().replaceAll("[^a-z0-9_\\\\]", "_");
}
}

View File

@ -6,6 +6,7 @@ import java.util.List;
import java.util.Map;
import org.gcube.application.geoportal.model.InvalidRecordException;
import org.gcube.application.geoportal.model.MOSI;
import org.gcube.application.geoportal.model.PostgisTable.Field;
import lombok.extern.slf4j.Slf4j;
@ -44,4 +45,11 @@ public class GpkgUtils {
}
return row;
}
public static Map<String,MOSI> loadMosiFromTable(File gpkgFile, String table){
log.info("Loading MOSIs from "+table+" in "+gpkgFile.getAbsoluteFile());
GeoPackage gpkg=open(gpkgFile);
gpkg.getFeatureDao(table);
}
}

View File

@ -2,37 +2,19 @@ package org.gcube.application.geoportal.utils;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.GregorianCalendar;
import java.util.Map;
import java.util.UUID;
import javax.xml.bind.JAXBException;
import org.gcube.application.geoportal.PostgisDBManagerI;
import org.gcube.application.geoportal.model.LayerDescriptor;
import org.gcube.application.geoportal.model.MOSI;
import org.gcube.application.geoportal.model.MOSI.Extent_Type;
import org.gcube.application.geoportal.model.PostgisTable;
import org.gcube.application.geoportal.model.PostgisTable.BBOX;
import org.gcube.application.geoportal.model.PublishException;
import org.gcube.spatial.data.geonetwork.GeoNetworkPublisher;
import org.gcube.spatial.data.geonetwork.LoginLevel;
import org.gcube.spatial.data.geonetwork.iso.tpl.ISOMetadataByTemplate;
import org.gcube.spatial.data.geonetwork.iso.tpl.MetadataDescriptor;
import org.gcube.spatial.data.geonetwork.iso.tpl.codelists.GeometricObjectType;
import org.gcube.spatial.data.geonetwork.iso.tpl.codelists.KeywordType;
import org.gcube.spatial.data.geonetwork.iso.tpl.codelists.ResponsiblePartyRole;
import org.gcube.spatial.data.geonetwork.iso.tpl.codelists.RestrictionCode;
import org.gcube.spatial.data.geonetwork.iso.tpl.codelists.TopicCategory;
import org.gcube.spatial.data.geonetwork.iso.tpl.codelists.TopologyLevel;
import org.gcube.spatial.data.geonetwork.iso.tpl.constraints.LegalConstraints;
import org.gcube.spatial.data.geonetwork.iso.tpl.constraints.ResourceConstraints;
import org.gcube.spatial.data.geonetwork.iso.tpl.extent.BoundingBox;
import org.gcube.spatial.data.geonetwork.iso.tpl.keys.KeywordSet;
import org.gcube.spatial.data.geonetwork.iso.tpl.keys.Thesaurus;
import org.gcube.spatial.data.geonetwork.iso.tpl.parties.Contact;
import org.gcube.spatial.data.geonetwork.iso.tpl.parties.ResponsibleParty;
import org.gcube.spatial.data.geonetwork.iso.tpl.spatial.VectorRepresentation;
import org.gcube.spatial.data.gis.GISInterface;
import org.gcube.spatial.data.gis.is.GeoServerDescriptor;
import org.gcube.spatial.data.gis.model.report.PublishResponse;
@ -50,6 +32,15 @@ import lombok.extern.slf4j.Slf4j;
public class Layers {
static {
// Register custom metadata template
try {
ISOMetadataByTemplate.registerTemplateFolder(Files.getFileFromResources("iso_templates/macros.ftlx"));
}catch(Throwable t) {
log.error("UNABLE TO REGISTER TEMPLATES",t);
}
}
public static void deleteLayer(LayerDescriptor desc, GISInterface gis, GeoServerDescriptor geoserver,LoginLevel loginLevel, PostgisDBManagerI db) throws Exception {
// delete fte
gis.deleteLayer(desc.getGeoserverWorkspace(), desc.getLayerName(), desc.getMetaID(), geoserver, loginLevel);
@ -138,53 +129,15 @@ public class Layers {
}
private static Metadata generateMetaForTemplate(LayerDescriptor layerDescriptor) {
private static Metadata generateMetaForTemplate(MOSI mosi, LayerDescriptor layerDescriptor,BBOX bbox) {
try {
MetadataDescriptor desc=new MetadataDescriptor();
desc.setResponsibleParties(Arrays.asList(
new ResponsibleParty("The scope ","the infra",ResponsiblePartyRole.DISTRIBUTOR,new Contact("my.mail@this.place.com","www.mipiacitu.com")),
new ResponsibleParty("Io","me stesso",ResponsiblePartyRole.POINT_OF_CONTACT,new Contact("point.of.contact.maiol@place.com","www.mipiacitu.com")),
new ResponsibleParty("Io","me stesso",ResponsiblePartyRole.AUTHOR,new Contact("point.of.contact.maiol@place.com","www.mipiacitu.com"))
));
// TODO Set layer info
mosi.setExtent(new Extent_Type(bbox.getMinLong(), bbox.getMaxLong(), bbox.getMaxLat(), bbox.getMinLat()));
desc.setAbstractField("My Abstract Field");
desc.addCredits("Fatto io");
desc.setCreationTime(new GregorianCalendar().getTime());
VectorRepresentation representation=new VectorRepresentation(
TopologyLevel.GEOMETRY_ONLY, 1000, GeometricObjectType.POINT);
desc.setSpatialRepresentation(representation);
desc.addKeywordSet(new KeywordSet(
KeywordType.THEME,
Collections.singleton("Species distribution"),
Thesaurus.INSPIRE_THEMES));
desc.addKeywordSet(new KeywordSet(Collections.singleton("My keyword")));
desc.setPurpose("Just for fun");
desc.setTitle("Il mio bel titolone");
desc.setUUIDIdentifier(UUID.randomUUID().toString());
desc.getExtent().addGeographicExtent(BoundingBox.WORLD_EXTENT);
// desc.setGeoServerDistributionInfo("http://geoserver.d4science.org/geoserver", "ws","wmpa", "speciesProb", "EPSG:4326",BoundingBox.WORLD_EXTENT);
desc.setSpatialResolution(0.5d);
desc.setConstraints(new ResourceConstraints("I'll tell you when",
new LegalConstraints(RestrictionCode.LICENSE,"CC-BY-SA"),
new LegalConstraints(RestrictionCode.LICENSE,"CC-BY-SA")));
desc.addTopicCategory(TopicCategory.ENVIRONMENT);
desc.setLineageStatement("I made with my own hands");
File metaFile=ISOMetadataByTemplate.createXML(desc);
File metaFile=;
return (Metadata) XML.unmarshal(metaFile);
}catch(IOException | TemplateException | JAXBException e) {
throw new RuntimeException("WORK ON THIS");

View File

@ -0,0 +1,86 @@
<#macro responsibleParty name organization mail site role>
<gmd:CI_ResponsibleParty>
<gmd:individualName>
<gco:CharacterString>${name}</gco:CharacterString>
</gmd:individualName>
<gmd:organisationName>
<gco:CharacterString>${organization}</gco:CharacterString>
</gmd:organisationName>
<gmd:contactInfo>
<gmd:CI_Contact>
<gmd:address>
<gmd:CI_Address>
<gmd:electronicMailAddress>
<gco:CharacterString>${mail}</gco:CharacterString>
</gmd:electronicMailAddress>
</gmd:CI_Address>
</gmd:address>
<gmd:onlineResource>
<gmd:CI_OnlineResource>
<gmd:linkage>
<gmd:URL>${site}</gmd:URL>
</gmd:linkage>
<gmd:protocol>
<gco:CharacterString>WWW:LINK-1.0-http--link</gco:CharacterString>
</gmd:protocol>
<gmd:name>
<gco:CharacterString>${name} site.</gco:CharacterString>
</gmd:name>
</gmd:CI_OnlineResource>
</gmd:onlineResource>
</gmd:CI_Contact>
</gmd:contactInfo>
<gmd:role>
<gmd:CI_RoleCode codeListValue="${role}"
codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#CI_RoleCode"/>
</gmd:role>
</gmd:CI_ResponsibleParty>
</#macro>
<#macro keyword values type thesaurus>
<gmd:descriptiveKeywords>
<gmd:MD_Keywords>
<#list values as value>
<#if value??>
<gmd:keyword>
<gco:CharacterString>${value}</gco:CharacterString>
</gmd:keyword>
</#if>
</#list>
<#if type??>
<gmd:type>
<gmd:MD_KeywordTypeCode codeListValue="${type}"
codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#MD_KeywordTypeCode"/>
</gmd:type>
</#if>
<#if thesaurus??>
<gmd:thesaurusName>
<gmd:CI_Citation>
<gmd:title>
<gco:CharacterString>${thesaurus.name}</gco:CharacterString>
</gmd:title>
<gmd:date>
<gmd:CI_Date>
<gmd:date>
<gco:Date>${thesaurus.date}</gco:Date>
</gmd:date>
<gmd:dateType>
<gmd:CI_DateTypeCode codeSpace="eng"
codeListValue="publication"
codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#CI_DateTypeCode"/>
</gmd:dateType>
</gmd:CI_Date>
</gmd:date>
</gmd:CI_Citation>
</gmd:thesaurusName>
</#if>
</gmd:MD_Keywords>
</gmd:descriptiveKeywords>
</#macro>

View File

@ -1,3 +1,432 @@
<#setting url_escaping_charset='ISO-8859-1'>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<tag></tag>
<#setting url_escaping_charset='ISO-8859-1'>
<#include "macros.ftlx">
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<gmd:MD_Metadata xmlns:gco="http://www.isotc211.org/2005/gco"
xmlns:fra="http://www.cnig.gouv.fr/2005/fra" xmlns:gmx="http://www.isotc211.org/2005/gmx"
xmlns:gmi="http://www.isotc211.org/2005/gmi" xmlns:gmd="http://www.isotc211.org/2005/gmd"
xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xlink="http://www.w3.org/1999/xlink">
<#compress>
<gmd:fileIdentifier>
<gco:CharacterString>${UUIDIdentifier}</gco:CharacterString>
</gmd:fileIdentifier>
<!--AVAILABLE LANGUAGE CODES ARE ENG & FR -->
<gmd:language>
<gmd:LanguageCode codeListValue="eng"
codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/ML_gmxCodelists.xml#LanguageCode">eng</gmd:LanguageCode>
</gmd:language>
<gmd:characterSet>
<gmd:MD_CharacterSetCode codeListValue="utf8"
codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#MD_CharacterSetCode">UTF-8</gmd:MD_CharacterSetCode>
</gmd:characterSet>
<gmd:hierarchyLevel>
<gmd:MD_ScopeCode codeSpace="eng" codeListValue="dataset"
codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#MD_ScopeCode">Dataset</gmd:MD_ScopeCode>
</gmd:hierarchyLevel>
<!-- RESPONSIBLE PARTIES : contact-->
<!-- Funzionari responsabili -->
<#list CM.FUR as name>
<gmd:contact>
<@responsibleParty name 'n/a' 'n/a' 'n/a' 'custodian'/>
</gmd:contact>
</#list>
<!-- Responsabili contenuti -->
<#list CM.CMR as name>
<gmd:contact>
<@responsibleParty name 'n/a' 'n/a' 'n/a' 'principalInvestigator'/>
</gmd:contact>
</#list>
<!-- Responsabili modulo -->
<#list CM.CMC as name>
<gmd:contact>
<@responsibleParty name 'n/a' 'n/a' 'n/a' 'author'/>
</gmd:contact>
</#list>
<!-- MIBACT -->
<!-- D4Science -->
<gmd:contact>
<@responsibleParty 'Sinibaldi, Fabio' 'D4Science' 'support@d4science.org' 'www.d4science.org' 'processor'/>
</gmd:contact>
<!-- PUBLICATION TIME -->
<gmd:dateStamp>
<gco:DateTime>${.now?iso_utc}</gco:DateTime>
</gmd:dateStamp>
<gmd:metadataStandardName>
<gco:CharacterString>ISO19115</gco:CharacterString>
</gmd:metadataStandardName>
<gmd:metadataStandardVersion>
<gco:CharacterString>2003/Cor.1:2006</gco:CharacterString>
</gmd:metadataStandardVersion>
<!-- SPATIAL REPRESENTATION INFO -->
<#include "Spatial.ftlx">
<!-- REFERENCE SYSTEM -->
<gmd:referenceSystemInfo>
<gmd:MD_ReferenceSystem>
<gmd:referenceSystemIdentifier>
<gmd:RS_Identifier>
<gmd:code>
<gco:CharacterString>${GE.GEP}</gco:CharacterString>
</gmd:code>
</gmd:RS_Identifier>
</gmd:referenceSystemIdentifier>
</gmd:MD_ReferenceSystem>
</gmd:referenceSystemInfo>
<!-- IDENTIFICATION INFO -->
<gmd:identificationInfo>
<gmd:MD_DataIdentification>
<gmd:citation>
<gmd:CI_Citation>
<#list OG.OGN>
<gmd:title>
<gco:CharacterString>${OG.OGN[0]}</gco:CharacterString>
</gmd:title>
<!-- Denominazione Ricognizione -->
<gmd:alternateTitle>
<gco:CharacterString>${RE.RCG.RCGV}</gco:CharacterString>
</gmd:alternateTitle>
<#items as alt_title>
<gmd:alternateTitle>
<gco:CharacterString>${alt_title}</gco:CharacterString>
</gmd:alternateTitle>
</#items>
<#else>
<gmd:title> <!-- Default title is ID-->
<gco:CharacterString>${CD.CDM}</gco:CharacterString>
</gmd:title>
</#list>
<gmd:date>
<gmd:CI_Date>
<gmd:date>
<!-- YEAR ONLY -->
<gco:Date>${CM.CMA}</gco:Date>
</gmd:date>
<gmd:dateType>
<gmd:CI_DateTypeCode codeSpace="eng"
codeListValue="creation"
codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#CI_DateTypeCode">Creation</gmd:CI_DateTypeCode>
</gmd:dateType>
</gmd:CI_Date>
</gmd:date>
<gmd:identifier>
<gmd:MD_Identifier>
<gmd:code>
<gco:CharacterString>${CD.CDM}</gco:CharacterString>
</gmd:code>
</gmd:MD_Identifier>
</gmd:identifier>
<#list ACC as acc>
<gmd:identifier>
<gmd:MD_Identifier>
<gmd:code>
<gco:CharacterString>${acc.accc}</gco:CharacterString>
</gmd:code>
<gmd:authority>
<gmd:CI_Citation>
<gmd:title>
<gco:CharacterString>${acc.acce}</gco:CharacterString>
</gmd:title>
</gmd:CI_Citation>
</gmd:authority>
</gmd:MD_Identifier>
</gmd:identifier>
</#list>
<#if CD.CBC??>
<gmd:identifier>
<gmd:MD_Identifier>
<gmd:code>
<gco:CharacterString>${CD.CBC}</gco:CharacterString>
</gmd:code>
</gmd:MD_Identifier>
</gmd:identifier>
</#if>>
<!-- TODO MIBACT cited responsible party-->
<#if CD.ESC??>
<gmd:citedResponsibleParty>
<@responsibleParty CD.ESC 'n/a' 'n/a' 'n/a' 'custodian'/>
<gmd:citedResponsibleParty>
</#if>
<#if CD.ECP??>
<gmd:citedResponsibleParty>
<@responsibleParty CD.ESC 'n/a' 'n/a' 'n/a' 'principalInvestigator'/>
<gmd:citedResponsibleParty>
</#if>
<!-- Presentation forms-->
<gmd:CI_PresentationFormCode
codeListValue="imageDigital"
codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#CI_PresentationFormCode">Image digital</gmd:CI_PresentationFormCode>
</gmd:presentationForm>
<gmd:CI_PresentationFormCode
codeListValue="mapDigital"
codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#CI_PresentationFormCode">Map digital</gmd:CI_PresentationFormCode>
</gmd:presentationForm>
<gmd:CI_PresentationFormCode
codeListValue="documentDigital"
codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#CI_PresentationFormCode">Document digital</gmd:CI_PresentationFormCode>
</gmd:presentationForm>
</gmd:CI_Citation>
</gmd:citation>
<gmd:abstract>
<gco:CharacterString>${DA.DES}</gco:CharacterString>
</gmd:abstract>
<gmd:purpose>
<gco:CharacterString>${OG.OGD}</gco:CharacterString>
</gmd:purpose>
<!-- TODO CREDITS-->
<gmd:credit>
<gco:CharacterString>Collaborazione MIBAC</gco:CharacterString>
</gmd:credit>
<!-- RESPONSIBLE PARTIES -->
<gmd:pointOfContact>
<@responsibleParty 'Valeria Boi' 'MIBACT' 'n/a' 'n/a' 'pointOfContact'/>
</gmd:pointOfContact>
<!-- MAINTENANCE -->
<gmd:resourceMaintenance>
<gmd:MD_MaintenanceInformation>
<gmd:maintenanceAndUpdateFrequency>
<gmd:MD_MaintenanceFrequencyCode
codeListValue="asNeeded"
codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#MD_MaintenanceFrequencyCode">As Needed</gmd:MD_MaintenanceFrequencyCode>
</gmd:maintenanceAndUpdateFrequency>
</gmd:MD_MaintenanceInformation>
</gmd:resourceMaintenance>
<!-- KEYWORDS -->
<!-- Tipo modulo-->
<!-- Ambito tutela-->
<!-- Ambito applicazione-->
<!-- Tipologia-->
<@keyword [CD.TSK,OG.AMB,OG.AMA,OG.OGT] 'discipline' />
<!-- Stato, Regione,Provincia,Comune,Toponimo-->
<@keyword [LC.LCS,LC.LCR,LC.LCP,LC.LCC]+LC.PVL 'place'/>
<!-- Rif. cronologico-->
<@keyword [DT.DTR,RE.RCG,RCGD] 'temporal'/>
<!-- INSPIRE THEME -->
<@keyword ['Area management / restriction / regulation zones & reporting units'] 'theme' {"name": "GEMET - INSPIRE themes, version 1.0", "date" : "3908-07-01" }/>
<!-- LEGAL ACCESS AND USE -->
<gmd:resourceConstraints>
<gmd:MD_Constraints>
<gmd:useLimitation>
<gco:CharacterString>USE LIMITATION NOTES </gco:CharacterString>
</gmd:useLimitation>
</gmd:MD_Constraints>
</gmd:resourceConstraints>
<gmd:resourceConstraints>
<gmd:MD_LegalConstraints>
<gmd:accessConstraints>
<gmd:MD_RestrictionCode codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#MD_RestrictionCode" codeListValue="license"/>
</gmd:accessConstraints>
</gmd:MD_LegalConstraints>
</gmd:resourceConstraints>
<gmd:resourceConstraints>
<gmd:MD_LegalConstraints>
<gmd:useConstraints>
<gmd:MD_RestrictionCode codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#MD_RestrictionCode" codeListValue="license"/>
</gmd:useConstraints>
</gmd:MD_LegalConstraints>
</gmd:resourceConstraints>
<!-- SPATIAL RESOLUTION & TOPIC CATEGORY-->
<gmd:spatialResolution>
<gmd:MD_Resolution>
<gmd:distance>
<gco:Distance
uom="http://schemas.opengis.net/iso/19139/20070417/resources/uom/gmxUom.xml#xpointer(//*[@gml:id='m'])">${spatialResolution}</gco:Distance>
</gmd:distance>
</gmd:MD_Resolution>
</gmd:spatialResolution>
<gmd:language>
<gmd:LanguageCode codeListValue="ita"
codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/ML_gmxCodelists.xml#LanguageCode">Italiano</gmd:LanguageCode>
</gmd:language>
<gmd:topicCategory>
<gmd:MD_TopicCategoryCode>society</gmd:MD_TopicCategoryCode>
</gmd:topicCategory>
<gmd:topicCategory>
<gmd:MD_TopicCategoryCode>archeology</gmd:MD_TopicCategoryCode>
</gmd:topicCategory>
<!-- EXTENT -->
<!-- TODO TEMPORAL EXTENT-->
<gmd:extent>
<gmd:EX_Extent>
<gmd:geographicElement>
<gmd:EX_GeographicBoundingBox>
<gmd:extentTypeCode>
<gco:Boolean>true</gco:Boolean>
</gmd:extentTypeCode>
<gmd:westBoundLongitude>
<gco:Decimal>${extent.west}</gco:Decimal>
</gmd:westBoundLongitude>
<gmd:eastBoundLongitude>
<gco:Decimal>${extent.east}</gco:Decimal>
</gmd:eastBoundLongitude>
<gmd:southBoundLatitude>
<gco:Decimal>${extent.south}</gco:Decimal>
</gmd:southBoundLatitude>
<gmd:northBoundLatitude>
<gco:Decimal>${extent.north}</gco:Decimal>
</gmd:northBoundLatitude>
</gmd:EX_GeographicBoundingBox>
</gmd:geographicElement>
</gmd:EX_Extent>
</gmd:extent>
</gmd:MD_DataIdentification>
</gmd:identificationInfo>
<!-- TODO ONLINE REsources and protocols -->
<!-- DATA QUALITY INFO -->
<gmd:dataQualityInfo>
<gmd:DQ_DataQuality>
<gmd:scope>
<gmd:DQ_Scope>
<gmd:level>
<gmd:MD_ScopeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/gmxCodelists.xml#MD_ScopeCode" codeListValue="dataset"/>
</gmd:level>
</gmd:DQ_Scope>
</gmd:scope>
<gmd:report>
<gmd:DQ_DomainConsistency xsi:type="gmd:DQ_DomainConsistency_Type">
<gmd:measureIdentification>
<gmd:RS_Identifier>
<gmd:code>
<gco:CharacterString>Conformity_001</gco:CharacterString>
</gmd:code>
<gmd:codeSpace>
<gco:CharacterString>INSPIRE</gco:CharacterString>
</gmd:codeSpace>
</gmd:RS_Identifier>
</gmd:measureIdentification>
<gmd:result>
<gmd:DQ_ConformanceResult xsi:type="gmd:DQ_ConformanceResult_Type">
<gmd:specification xlink:href="">
<gmd:CI_Citation>
<gmd:title>
<gco:CharacterString>COMMISSION REGULATION (EU) No 1089/2010 of 23 November 2010 implementing Directive 2007/2/EC of the European Parliament and of the Council as regards interoperability of spatial data sets and services</gco:CharacterString>
</gmd:title>
<gmd:date>
<gmd:CI_Date>
<gmd:date>
<gco:Date>2010-12-08</gco:Date>
</gmd:date>
<gmd:dateType><gmd:CI_DateTypeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue="publication" /></gmd:dateType>
</gmd:CI_Date>
</gmd:date>
</gmd:CI_Citation>
</gmd:specification>
<gmd:explanation><gco:CharacterString>See the referenced specification</gco:CharacterString></gmd:explanation><gmd:pass gco:nilReason="inapplicable" /></gmd:DQ_ConformanceResult>
</gmd:result></gmd:DQ_DomainConsistency></gmd:report>
<gmd:lineage>
<gmd:LI_Lineage>
<gmd:statement>
<gco:CharacterString>${lineageStatement}</gco:CharacterString>
</gmd:statement>
</gmd:LI_Lineage>
</gmd:lineage>
</gmd:DQ_DataQuality>
</gmd:dataQualityInfo>
</gmd:MD_Metadata>
</#compress>

View File

@ -1,11 +1,39 @@
package org.gcube.application.geoportal;
import java.io.File;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.HashSet;
import org.gcube.application.geoportal.model.DBInteractionException;
import org.gcube.application.geoportal.model.DataParsingException;
import org.gcube.application.geoportal.model.GeoPackageInteractionException;
import org.gcube.application.geoportal.model.MOSI;
import org.gcube.application.geoportal.model.MOSI.CD_Type;
import org.gcube.application.geoportal.model.MOSI.CD_Type.ACC_Type;
import org.gcube.application.geoportal.model.MOSI.CM_Type;
import org.gcube.application.geoportal.model.MOSI.DA_Type;
import org.gcube.application.geoportal.model.MOSI.DO_Type;
import org.gcube.application.geoportal.model.MOSI.DT_Type;
import org.gcube.application.geoportal.model.MOSI.Extent_Type;
import org.gcube.application.geoportal.model.MOSI.GE_Type;
import org.gcube.application.geoportal.model.MOSI.GE_Type.GEC_Type;
import org.gcube.application.geoportal.model.MOSI.IP_Type;
import org.gcube.application.geoportal.model.MOSI.IP_Type.IAP_Type;
import org.gcube.application.geoportal.model.MOSI.LC_Type;
import org.gcube.application.geoportal.model.MOSI.MT_Type;
import org.gcube.application.geoportal.model.MOSI.MT_Type.MTA_Type;
import org.gcube.application.geoportal.model.MOSI.OG_Type;
import org.gcube.application.geoportal.model.MOSI.RE_Type;
import org.gcube.application.geoportal.model.MOSI.RE_Type.FOI_Type;
import org.gcube.application.geoportal.model.MOSI.RE_Type.MTP_Type;
import org.gcube.application.geoportal.model.MOSI.TU_Type;
import org.gcube.application.geoportal.model.MOSI.TU_Type.NVC_Type;
import org.gcube.application.geoportal.model.MOSI.TU_Type.STU_Type;
import org.gcube.application.geoportal.model.MOSI.VR_Type;
import org.gcube.application.geoportal.model.PostgisTable;
import org.gcube.application.geoportal.utils.Files;
import org.gcube.application.geoportal.utils.GpkgUtils;
import org.junit.BeforeClass;
@ -24,6 +52,9 @@ public class GeopackageTests {
File gpkgFile = Files.getFileFromResources("gpkg/ArcheoPrevTemplateItalia.gpkg");
gpkg=GpkgUtils.open(gpkgFile);
}
@Test
@ -40,4 +71,113 @@ public class GeopackageTests {
public void failMissingGeom() throws SQLException, GeoPackageInteractionException, DBInteractionException, DataParsingException {
factory.fromGPKGFeatureTable(gpkg, "MOSI_SW");
}
@Test
public void loadMosi() {
// factory.fromGPKGFeatureTable(gpkg, featureTableName)
}
public static MOSI fromTable(PostgisDBManagerI db, PostgisTable mosiTable) throws SQLException {
ResultSet rs= db.queryAll(mosiTable);
CD_Type CD=new CD_Type();
HashSet<ACC_Type> ACCs=new HashSet<>();
OG_Type OG=new OG_Type();
HashSet<String> OGNs=new HashSet<>();
LC_Type LC=new LC_Type();
HashSet<String> PVLs=new HashSet<>();
DT_Type DT=new DT_Type();
DA_Type DA=new DA_Type();
HashSet<String> OGMs=new HashSet<>();
GE_Type GE=new GE_Type();
HashSet<GEC_Type> GECs=new HashSet<>();
TU_Type TU=new TU_Type();
HashSet<NVC_Type> NVCs=new HashSet<>();
HashSet<STU_Type> STUs=new HashSet<>();
RE_Type RE=new RE_Type();
HashSet<MTP_Type> MTPs=new HashSet<>();
HashSet<FOI_Type> FOIs=new HashSet<>();
IP_Type IP=new IP_Type();
HashSet<IAP_Type> IAPs=new HashSet<>();
MT_Type MT=new MT_Type();
HashSet<MTA_Type> MTAs=new HashSet<>();
VR_Type VR=new VR_Type();
DO_Type DO=new DO_Type();
CM_Type CM=new CM_Type();
Extent_Type extent=new Extent_Type();
HashMap<String, String> singleValues=new HashMap<String, String>();
ResultSetMetaData meta=rs.getMetaData();
int colCount=meta.getColumnCount();
String[] fields=new String[colCount];
for(int i=0; i<meta.getColumnCount(); i++) {
fields[i]=meta.getColumnName(i+1);
}
while(rs.next()) {
//Set values into map if not null
for(String field:fields) {
String value=rs.getString(field);
if(value!=null)singleValues.putIfAbsent(field, value);
}
//Collect multiple values if not null
if(rs.getString("acce")!=null)
ACCs.add(new ACC_Type(rs.getString("acce"), rs.getString("accc"), rs.getString("accs")));
if(rs.getString("ogn")!=null)
OGNs.add(rs.getString("ogn"));
if(rs.getString("pvl")!=null)
PVLs.add(rs.getString("pvl"));
if(rs.getString("ogm")!=null)
OGMs.add(rs.getString("ogm"));
if(rs.getString("gecx")!=null)
GECs.add(new GEC_Type(rs.getString("gecx"), rs.getString("gecy")));
if(rs.getString("nvct")!=null||rs.getString("nvcm")!=null||rs.getString("nvce")!=null||rs.getString("nvcp")!=null||rs.getString("nvcn")!=null)
NVCs.add(new NVC_Type(rs.getString("nvct"),rs.getString("nvcm"),rs.getString("nvce"),rs.getString("nvcp"),rs.getString("nvcn")));
if(rs.getString("stue")!=null||rs.getString("stut")!=null||rs.getString("stus")!=null)
STUs.add(new STU_Type(rs.getString("stue"),rs.getString("stut"),rs.getString("stus")));
if(rs.getString("mtpc")!=null)
MTPs.add(new MTP_Type(rs.getString("mtpc"),rs.getString("mtpz")));
if(rs.getString("foit")!=null||rs.getString("foir")!=null||rs.getString("foia")!=null||rs.getString("foiq")!=null||rs.getString("foif")!=null||rs.getString("foio")!=null||rs.getString("foin")!=null)
FOIs.add(new FOI_Type(rs.getString("foit"),rs.getString("foir"),rs.getString("foia"),rs.getString("foiq"),rs.getString("foif"),rs.getString("foio"),rs.getString("foin")));
if(rs.getString("iapn")!=null)
IAPs.add(new IAP_Type(rs.getString("iapn"), rs.getString("iapr"), rs.getString("iapi"), rs.getString("iaps")));
if(rs.getString("mtap")!=null||rs.getString("mtam")!=null||rs.getString("mtax")!=null||rs.getString("mtar")!=null||rs.getString("mtas")!=null)
MTAs.add(new MTA_Type(rs.getString("mtap"),rs.getString("mtam"),rs.getString("mtax"),rs.getString("mtar"),rs.getString("mtas")));
}
return new MOSI(CD,OG,LC,DT,DA,GE,TU,RE,IP,MT,VR,DO,CM,extent);
}
}