Skip to content

Commit

Permalink
Merge branch 'master' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
claeis committed Apr 3, 2019
2 parents a0182f5 + 72cf5c1 commit 7903180
Show file tree
Hide file tree
Showing 40 changed files with 2,510 additions and 81 deletions.
9 changes: 5 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ allprojects {
targetCompatibility = "1.6"
}

version '1.10.0'+System.getProperty('release','-SNAPSHOT')
version '1.11.0'+System.getProperty('release','-SNAPSHOT')

configurations {
deployerJars
Expand All @@ -16,12 +16,13 @@ configurations {
// to get the latest SNAPSHOT uncomment the following lines
//configurations.all {
// check for updates every build
// resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
// resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
//}

dependencies {
compile group: 'ch.interlis', name: 'iox-ili', version: '1.20.10'
compile group: 'ch.interlis', name: 'ili2c-tool', version: "4.7.10"
compile group: 'ch.interlis', name: 'iox-ili', version: '1.20.11'
compile group: 'ch.interlis', name: 'ili2c-tool', version: "5.0.0"
compile group: 'ch.interlis', name: 'ili2c-core', version: "5.0.0"
testCompile group: 'junit', name: 'junit', version: '4.12'
deployerJars "org.apache.maven.wagon:wagon-ftp:3.0.0"
testRuntime project('demoplugin')
Expand Down
15 changes: 15 additions & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
LATEST VERSION
-----------------------------

ilivalidator 1.11.0 (2019-04-03)
-----------------------------
- incomplete attribute path in error message
- new config parameter to report inconsistent model version
- new function --check-repo-data
- new function --updateIliData
- new function --createIliData
- GUI: create menu items for cmdline options
- localize validation messages
- fixed: Xtflog contains not all messages
- fixed: invalid ring lines Error - failed to build polygons
- fixed: Constraints in association: compare objects not possible
- iox-ili-1.20.11
- ili2c-5.0.0

ilivalidator 1.10.0 (2018-12-09)
-----------------------------
- GUI: use model names as additionalModels
Expand Down
186 changes: 123 additions & 63 deletions docs/ilivalidator.rst

Large diffs are not rendered by default.

122 changes: 122 additions & 0 deletions src/org/interlis2/validator/CheckRepoDataTool.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
package org.interlis2.validator;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import ch.ehi.basics.logging.EhiLogger;
import ch.ehi.basics.settings.Settings;
import ch.interlis.ilirepository.IliManager;
import ch.interlis.ilirepository.impl.RepositoryAccess;
import ch.interlis.iom.IomObject;

public class CheckRepoDataTool {

public static boolean launch(Settings settings) {
return new CheckRepoDataTool().checkRepoData(settings);
}

private boolean checkRepoData(Settings settings) {
try {
String repository = settings.getValue(Validator.SETTING_REPOSITORY);
if (repository == null || repository.isEmpty()) {
throw new Exception("Repository should be given as a parameter!");
}

// Get the IliDataXml from the Repository
RepositoryAccess reposAccess = new RepositoryAccess();
File localCopyOfRemoteOriginalIliDataXml = reposAccess.getLocalFileLocation(repository, IliManager.ILIDATA_XML, 0, null);
if(localCopyOfRemoteOriginalIliDataXml == null) {
throw new Exception(IliManager.ILIDATA_XML+" could not be found in <"+repository+">");
}

IomObject[] ilidataContents = UpdateIliDataTool.readIliData(localCopyOfRemoteOriginalIliDataXml);
if (ilidataContents == null) {
throw new Exception("Contents of the "+IliManager.ILIDATA_XML+" should not be empty!");
}

IomObject[] actualIliDatas = findActualIliDatas(ilidataContents);
for (IomObject currentObj : actualIliDatas) {
IomObject files = currentObj.getattrobj(ch.interlis.models.DatasetIdx16.DataIndex.DatasetMetadata.tag_files, 0);
IomObject file = files.getattrobj(ch.interlis.models.DatasetIdx16.DataFile.tag_file, 0);
String filepath = repository + "/" + file.getattrvalue(ch.interlis.models.DatasetIdx16.File.tag_path);

// Validate IliDataXml
boolean runValidation = Validator.runValidation(new String[] { filepath }, null);
if (!runValidation) {
return false;
}
}
} catch (Exception e) {
EhiLogger.logError(e);
return false;
}
return true;
}

public IomObject[] findActualIliDatas(IomObject[] ilidataContents) throws Exception {
Map<String, List<IomObject>> actualIliDatas = new HashMap<String, List<IomObject>>();
try {
for (IomObject currentIomObj : ilidataContents) {
String currentID = currentIomObj.getattrvalue(ch.interlis.models.DatasetIdx16.Metadata.tag_id);
String currentpreVersion = currentIomObj.getattrvalue(ch.interlis.models.DatasetIdx16.Metadata.tag_precursorVersion);
if (currentpreVersion == null || currentpreVersion.isEmpty()) {
// then it has a new DatasetID
appendNewIomObj(actualIliDatas, currentIomObj, currentID);
} else {
List<IomObject> iomObj = actualIliDatas.get(currentID);
if (iomObj == null || iomObj.isEmpty()) {
List<IomObject> objectList = new ArrayList<IomObject>();
actualIliDatas.put(currentID, objectList);
} else {
appendNewIomObj(actualIliDatas, currentIomObj, currentID);
String[] precursorValues = findAllPrecursorVersions(iomObj);
if (precursorValues != null) {
for (int i = 0; i < iomObj.size(); i++) {
String currentVersionName = iomObj.get(i).getattrvalue(ch.interlis.models.DatasetIdx16.Metadata.tag_version);
for (String preValue : precursorValues) {
if (preValue.equals(currentVersionName)) {
iomObj.remove(i);
}
}
}
}
}
}
}
} catch (Exception e) {
throw new Exception(e);
}
List<IomObject> returnValues = new ArrayList<IomObject>();
for (List<IomObject> values : actualIliDatas.values()) {
for (IomObject iomObj : values) {
returnValues.add(iomObj);
}
}

return returnValues.toArray(new IomObject[returnValues.size()]);
}

private String[] findAllPrecursorVersions(List<IomObject> iomObj) {
List<String> returnPreValues = new ArrayList<String>();
for (int i = 0; i < iomObj.size(); i++) {
String tmpPrecursor = iomObj.get(i).getattrvalue(ch.interlis.models.DatasetIdx16.Metadata.tag_precursorVersion);
if (tmpPrecursor != null) {
returnPreValues.add(tmpPrecursor);
}
}
return returnPreValues.toArray(new String[returnPreValues.size()]);
}

private void appendNewIomObj(Map<String, List<IomObject>> actualIliDatas, IomObject currentIomObj,
String currentID) {
List<IomObject> iomObj = actualIliDatas.get(currentID);
if (iomObj == null) {
iomObj = new ArrayList<IomObject>();
}
iomObj.add(currentIomObj);
actualIliDatas.put(currentID, iomObj);
}
}
Loading

0 comments on commit 7903180

Please sign in to comment.