diff --git a/pom.xml b/pom.xml
index 411e873..b40d92a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0
io.frictionlessdata
datapackage-java
- 0.6.11-SNAPSHOT
+ 0.6.12-SNAPSHOT
jar
https://github.com/frictionlessdata/datapackage-java/issues
@@ -22,7 +22,7 @@
8
${java.version}
${java.version}
- 0.6.11
+ 0.6.12
1.3
5.9.1
2.0.5
@@ -230,19 +230,21 @@
+
+
io.frictionlessdata
tableschema-java
- 0.6.2-SNAPSHOT
+ 0.6.12-SNAPSHOT
compile
--->
+
diff --git a/src/main/java/io/frictionlessdata/datapackage/Package.java b/src/main/java/io/frictionlessdata/datapackage/Package.java
index ee33d8d..3c5f970 100644
--- a/src/main/java/io/frictionlessdata/datapackage/Package.java
+++ b/src/main/java/io/frictionlessdata/datapackage/Package.java
@@ -535,7 +535,10 @@ public void write (File outputDir, boolean zipCompressed) throws Exception {
for (Resource r : resourceList) {
r.writeData(outFs.getPath(parentDirName ));
- r.writeSchema(outFs.getPath(parentDirName));
+
+ if (null != r.getSchema()) {
+ r.writeSchema(outFs.getPath(parentDirName));
+ }
// write out dialect file only if not null or URL
String dialectP = r.getPathForWritingDialect();
diff --git a/src/main/java/io/frictionlessdata/datapackage/resource/AbstractResource.java b/src/main/java/io/frictionlessdata/datapackage/resource/AbstractResource.java
index 7f7a839..1398f65 100644
--- a/src/main/java/io/frictionlessdata/datapackage/resource/AbstractResource.java
+++ b/src/main/java/io/frictionlessdata/datapackage/resource/AbstractResource.java
@@ -11,6 +11,7 @@
import io.frictionlessdata.datapackage.exceptions.DataPackageException;
import io.frictionlessdata.datapackage.exceptions.DataPackageValidationException;
import io.frictionlessdata.tableschema.Table;
+import io.frictionlessdata.tableschema.exception.ForeignKeyException;
import io.frictionlessdata.tableschema.fk.ForeignKey;
import io.frictionlessdata.tableschema.io.FileReference;
import io.frictionlessdata.tableschema.io.URLFileReference;
@@ -243,16 +244,62 @@ public List getTables() throws Exception {
return tables;
}
- public void checkRelations() {
+ public void checkRelations(List> resources) throws Exception {
if (null != schema) {
for (ForeignKey fk : schema.getForeignKeys()) {
fk.validate();
fk.getReference().validate();
}
- for (ForeignKey fk : schema.getForeignKeys()) {
- if (null != fk.getReference().getResource()) {
- //Package pkg = new Package(fk.getReference().getDatapackage(), true);
- // TODO fix this
+ Iterator