Skip to content

Commit

Permalink
refactor(model): validator-core - remove support for XML models (refs #…
Browse files Browse the repository at this point in the history
  • Loading branch information
mborne committed Aug 8, 2024
1 parent e1458d7 commit b629fa1
Show file tree
Hide file tree
Showing 12 changed files with 6 additions and 253 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import org.apache.logging.log4j.MarkerManager;
import org.locationtech.jts.geom.Geometry;

import com.ctc.wstx.util.StringUtil;

import fr.ign.validator.Context;
import fr.ign.validator.Version;
import fr.ign.validator.command.options.DocumentEmpriseOption;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import fr.ign.validator.tools.ModelHelper;

/**
* Common implementation for JSON and XML ModelReader.
* Common implementation for JSON and XML ModelReader (removed).
*
* @author MBorne
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public interface ModelReader {
public String getFormat();

/**
* Read File as a DocumentModel (files.xml)
* Read File as a DocumentModel
*
* @param documentModelPath
* @return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.net.URL;

import fr.ign.validator.exception.InvalidModelException;

/**
* Create ModelReader instances
*
Expand All @@ -26,7 +28,7 @@ private ModelReaderFactory() {
*/
public static ModelReader createModelReader(URL url) {
if (url.toString().endsWith(".xml")) {
return new XmlModelReader();
throw new InvalidModelException("Fail to load "+url+" (XML model support has been removed, use JSON format)");
} else {
return new JsonModelReader();
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
import java.util.List;

import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

import fr.ign.validator.data.Attribute;
import fr.ign.validator.io.xml.AttributeTypeAdapter;
import fr.ign.validator.validation.Validator;
import fr.ign.validator.validation.attribute.AttributeRequiredValidator;
import fr.ign.validator.validation.attribute.CharactersValidator;
Expand All @@ -24,7 +22,6 @@
*
* @param <T> the matching java type
*/
@XmlJavaTypeAdapter(AttributeTypeAdapter.class)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
@JsonInclude(value = Include.NON_NULL)
public abstract class AttributeType<T> implements Model, Cloneable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Prototype based factory providing AttributeType creation by name (Boolean,
* Double, etc.)
*
* @see src/main/resources/META-INF/services/fr.ign.validator.model.AttributeType
* @see src/main/resources/META-INF/services/fr.ign.validator.model.AttributeType containing the list of this types.
*
* @author MBorne
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
Expand All @@ -33,10 +27,6 @@
*
* @author MBorne
*/
@XmlRootElement(name = "document")
@XmlType(propOrder = {
"name", "regexp", "fileModels", "staticTables"
})
public class DocumentModel implements Model {
public static final Logger log = LogManager.getRootLogger();
public static final Marker MARKER = MarkerManager.getMarker("DocumentModel");
Expand Down Expand Up @@ -103,7 +93,6 @@ public void setName(String name) {
this.name = name;
}

@XmlTransient
public DocumentConstraints getConstraints() {
return constraints;
}
Expand Down Expand Up @@ -132,8 +121,6 @@ public void setRegexp(String regexp) {
this.constraints.setFolderName(regexp);
}

@XmlElementWrapper(name = "files")
@XmlElement(name = "file")
@JsonProperty("files")
public List<FileModel> getFileModels() {
return fileModels;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;

import com.fasterxml.jackson.annotation.JsonProperty;

import fr.ign.validator.model.type.GeometryType;
Expand All @@ -18,10 +12,6 @@
*
* @author MBorne
*/
@XmlRootElement
@XmlType(propOrder = {
"name", "description", "attributes", "constraints"
})
public class FeatureType implements Model {
/**
* Parent (optional)
Expand Down Expand Up @@ -72,13 +62,11 @@ public FeatureType getParent() {
*
* @param featureType
*/
@XmlTransient
public void setParent(FeatureType parent) {
this.parent = parent;
}

@Override
@XmlElement(name = "typeName")
public String getName() {
return name;
}
Expand Down Expand Up @@ -120,7 +108,6 @@ public String getDescription() {
return description;
}

@XmlElement
public void setDescription(String description) {
this.description = description;
}
Expand All @@ -136,8 +123,6 @@ public List<AttributeType<?>> getAttributes() {
return attributes;
}

@XmlElementWrapper(name = "attributes")
@XmlElement(name = "attribute")
@JsonProperty("columns")
public void setAttributes(List<AttributeType<?>> attributes) {
this.attributes = attributes;
Expand Down
Loading

0 comments on commit b629fa1

Please sign in to comment.