use of org.teiid.metadata.Schema in project teiid by teiid.
the class MaterializationManager method doMaterializationActions.
private void doMaterializationActions(VDBMetaData vdb, MaterializationAction action) {
TransformationMetadata metadata = vdb.getAttachment(TransformationMetadata.class);
if (metadata == null) {
return;
}
Set<String> imports = vdb.getImportedModels();
MetadataStore store = metadata.getMetadataStore();
// schedule materialization loads and do the start actions
for (Schema schema : store.getSchemaList()) {
if (imports.contains(schema.getName())) {
continue;
}
for (Table table : schema.getTables().values()) {
// find external matview table
if (!table.isVirtual() || !table.isMaterialized() || !Boolean.valueOf(table.getProperty(MaterializationMetadataRepository.ALLOW_MATVIEW_MANAGEMENT, false))) {
continue;
}
action.process(table);
}
}
}
use of org.teiid.metadata.Schema in project teiid by teiid.
the class MaterializationManager method nodeDropped.
@Override
public void nodeDropped(String nodeName) {
for (VDBMetaData vdb : getVDBRepository().getVDBs()) {
TransformationMetadata metadata = vdb.getAttachment(TransformationMetadata.class);
if (metadata == null) {
continue;
}
for (ModelMetaData model : vdb.getModelMetaDatas().values()) {
if (vdb.getImportedModels().contains(model.getName())) {
continue;
}
MetadataStore store = metadata.getMetadataStore();
Schema schema = store.getSchema(model.getName());
for (Table t : schema.getTables().values()) {
if (t.isVirtual() && t.isMaterialized() && t.getMaterializedTable() != null) {
String allow = t.getProperty(MaterializationMetadataRepository.ALLOW_MATVIEW_MANAGEMENT, false);
if (allow == null || !Boolean.valueOf(allow)) {
continue;
}
// reset the pending job if there is one.
int update = resetPendingJob(vdb, t, nodeName);
if (update > 0) {
String ttlStr = t.getProperty(MaterializationMetadataRepository.MATVIEW_TTL, false);
if (ttlStr == null) {
ttlStr = String.valueOf(Long.MAX_VALUE);
}
if (ttlStr != null) {
long ttl = Long.parseLong(ttlStr);
if (ttl > 0) {
// run the job
CompositeVDB cvdb = getVDBRepository().getCompositeVDB(new VDBKey(vdb.getName(), vdb.getVersion()));
scheduleSnapshotJob(cvdb, t, ttl, 0L, true);
}
}
}
}
}
}
}
}
use of org.teiid.metadata.Schema in project teiid by teiid.
the class RestASMBasedWebArchiveBuilder method getContent.
@Override
public byte[] getContent(VDBMetaData vdb) throws IOException {
MetadataStore metadataStore = vdb.getAttachment(TransformationMetadata.class).getMetadataStore();
Properties props = new Properties();
String fullName = vdb.getName() + "_" + vdb.getVersion();
props.setProperty("${context-name}", fullName);
props.setProperty("${vdb-name}", vdb.getName());
props.setProperty("${vdb-version}", String.valueOf(vdb.getVersion()));
props.setProperty("${api-page-title}", fullName + " API");
String securityType = vdb.getPropertyValue(REST_NAMESPACE + "security-type");
String securityDomain = vdb.getPropertyValue(REST_NAMESPACE + "security-domain");
String securityRole = vdb.getPropertyValue(REST_NAMESPACE + "security-role");
props.setProperty("${security-role}", ((securityRole == null) ? "rest" : securityRole));
props.setProperty("${security-domain}", ((securityDomain == null) ? "teiid-security" : securityDomain));
if (securityType == null) {
securityType = "httpbasic";
}
if (securityType.equalsIgnoreCase("none")) {
props.setProperty("${security-content}", "");
} else if (securityType.equalsIgnoreCase("httpbasic")) {
props.setProperty("${security-content}", replaceTemplates(getFileContents("rest-war/httpbasic.xml"), props));
}
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
ZipOutputStream out = new ZipOutputStream(byteStream);
writeEntry("WEB-INF/web.xml", out, replaceTemplates(getFileContents("rest-war/web.xml"), props).getBytes());
writeEntry("WEB-INF/jboss-web.xml", out, replaceTemplates(getFileContents("rest-war/jboss-web.xml"), props).getBytes());
writeEntry("api.html", out, replaceTemplates(getFileContents("rest-war/api.html"), props).getBytes());
writeDirectoryEntry(out, "swagger-ui-2.1.1.zip");
String version = vdb.getVersion();
VDBKey vdbKey = new VDBKey(vdb.getName(), vdb.getVersion());
ArrayList<String> applicationViews = new ArrayList<String>();
for (ModelMetaData model : vdb.getModelMetaDatas().values()) {
Schema schema = metadataStore.getSchema(model.getName());
if (schema == null) {
// OTHER type, which does not have a corresponding Teiid schema
continue;
}
byte[] viewContents = getViewClass(vdb.getName(), version, model.getName(), schema, true);
if (viewContents != null) {
writeEntry("WEB-INF/classes/org/teiid/jboss/rest/" + model.getName() + ".class", out, viewContents);
applicationViews.add(schema.getName());
}
}
writeEntry("WEB-INF/classes/org/teiid/jboss/rest/TeiidRestApplication.class", out, getApplicationClass(applicationViews));
writeEntry("META-INF/MANIFEST.MF", out, getFileContents("rest-war/MANIFEST.MF").getBytes());
byte[] bytes = getBootstrapServletClass(vdb.getName(), vdb.getDescription() == null ? vdb.getName() : vdb.getDescription(), vdbKey.getSemanticVersion(), new String[] { "http" }, File.separator + props.getProperty("${context-name}"), "org.teiid.jboss.rest", true);
writeEntry("WEB-INF/classes/org/teiid/jboss/rest/Bootstrap.class", out, bytes);
writeEntry("images/teiid_logo_450px.png", out, getBinaryFileContents("rest-war/teiid_logo_450px.png"));
out.close();
return byteStream.toByteArray();
}
use of org.teiid.metadata.Schema in project teiid by teiid.
the class CompositeVDB method getUDF.
private UDFMetaData getUDF() {
UDFMetaData mergedUDF = new UDFMetaData();
if (this.udf != null) {
mergedUDF.addFunctions(this.udf);
}
for (Schema schema : store.getSchemas().values()) {
Collection<FunctionMethod> funcs = schema.getFunctions().values();
mergedUDF.addFunctions(schema.getName(), funcs);
}
if (this.cmr != null) {
// system scoped common source functions
for (ConnectorManager cm : this.cmr.getConnectorManagers().values()) {
List<FunctionMethod> funcs = cm.getPushDownFunctions();
mergedUDF.addFunctions(CoreConstants.SYSTEM_MODEL, funcs);
}
}
if (this.children != null) {
// udf model functions - also scoped to the model
for (CompositeVDB child : this.children.values()) {
UDFMetaData funcs = child.getUDF();
if (funcs != null) {
mergedUDF.addFunctions(funcs);
}
}
}
return mergedUDF;
}
use of org.teiid.metadata.Schema in project teiid by teiid.
the class EventDistributorImpl method updateModified.
private void updateModified(boolean data, String vdbName, String vdbVersion, String schema, String... objectNames) {
Schema s = getSchema(vdbName, vdbVersion, schema);
if (s == null) {
return;
}
long ts = System.currentTimeMillis();
for (String name : objectNames) {
Table table = s.getTables().get(name);
if (table == null) {
continue;
}
if (data) {
table.setLastDataModification(ts);
} else {
table.setLastModified(ts);
}
}
}
Aggregations