Skip to content
This repository has been archived by the owner on Nov 11, 2020. It is now read-only.

Commit

Permalink
TEIID-5394: Adding support model visibility overrides, grantall, data…
Browse files Browse the repository at this point in the history
… role conflict finding, support for -vdb.ddl files
  • Loading branch information
rareddy committed Sep 14, 2018
1 parent 3dfcb56 commit 124fb55
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions src/main/java/org/teiid/VdbMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.teiid.adminapi.DataPolicy;
import org.teiid.adminapi.impl.DataPolicyMetadata;
import org.teiid.adminapi.impl.VDBImportMetadata;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.adminapi.impl.VDBMetadataParser;
Expand Down Expand Up @@ -90,6 +92,12 @@ public void execute() throws MojoExecutionException, MojoFailureException {
Set<File> directories = new LinkedHashSet<>();
gatherContents(f, directories);

// do not allow vdb-import in the case of VDB represented with .ddl
if (vdb.getName().endsWith("-vdb.ddl")) {
addFile(archive, "META-INF/vdb.ddl", vdb);
return;
}

// check if the VDB has any vdb imports, if yes, then check the dependencies
VDBMetaData top = VDBMetadataParser.unmarshell(new FileInputStream(vdb));
if (!top.getVDBImports().isEmpty()) {
Expand Down Expand Up @@ -117,12 +125,31 @@ public void execute() throws MojoExecutionException, MojoFailureException {

gatherContents(vdbDir, directories);

child.getModelMetaDatas().forEach((k,v) -> top.addModel(v));
top.getVisibilityOverrides().putAll(child.getVisibilityOverrides());
child.getModelMetaDatas().forEach((k, v) -> {
top.addModel(v);
String visibilityOverride = top.getPropertyValue(v.getName() + ".visible"); //$NON-NLS-1$
if (visibilityOverride != null) {
boolean visible = Boolean.valueOf(visibilityOverride);
top.setVisibilityOverride(v.getName(), visible);
}
});

child.getOverrideTranslatorsMap().forEach((k,v) -> top.addOverideTranslator(v));

if (importee.isImportDataPolicies()) {
child.getDataPolicyMap().forEach((k,v) -> top.addDataPolicy(v));
}
if (importee.isImportDataPolicies()) {
for (DataPolicy dp : child.getDataPolicies()) {
DataPolicyMetadata role = (DataPolicyMetadata)dp;
if (top.addDataPolicy(role) != null) {
throw new MojoExecutionException(top.getName() + "." + top.getVersion()
+ " imports a conflicting role " + role.getName() + " from "
+ child.getName() + "." + child.getVersion());
}
if (role.isGrantAll()) {
role.setSchemas(child.getModelMetaDatas().keySet());
}
}
}
matched = importee;
break;
}
Expand Down Expand Up @@ -196,7 +223,7 @@ private File getVDBFile() {
File[] list = f.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.endsWith("-vdb.xml");
return name.endsWith("-vdb.xml") || name.endsWith("-vdb.ddl");
}
});
if (list.length != 0) {
Expand Down

0 comments on commit 124fb55

Please sign in to comment.