/* * @see org.teiid.query.metadata.QueryMetadataInterface#getExtensionProperties(java.lang.Object) */ @Override public Properties getExtensionProperties(Object metadataID) { CoreArgCheck.isInstanceOf(MetadataRecord.class, metadataID); MetadataRecord metadataRecord = (MetadataRecord) metadataID; String uuid = metadataRecord.getUUID(); EObject eObj = lookupEObject(uuid); Properties extProps = new Properties(); // Create get annotation for the EObject and lookup properties if (eObj != null && eObj.eResource() != null && eObj.eResource() instanceof EmfResource) { EmfResource emfResource = (EmfResource) eObj.eResource(); ModelContents contents = new ModelContents(emfResource); Annotation annotation = contents.getAnnotation(eObj); if (annotation != null) { Iterator entryIter = annotation.getTags().entrySet().iterator(); while (entryIter.hasNext()) { Map.Entry entry = (Map.Entry) entryIter.next(); extProps.setProperty((String) entry.getKey(), (String) entry.getValue()); } } } return extProps; }
/** * {@inheritDoc} * * @see * org.teiid.designer.transformation.metadata.TransformationMetadata#findChildRecordsForColumns(org.teiid.designer.core.metadata.runtime.MetadataRecord, * char, java.util.List) */ @Override protected Collection findChildRecordsForColumns( MetadataRecord parentRecord, char childRecordType, List uuids) throws Exception { Collection kids = findChildRecords(parentRecord, childRecordType); ArrayList<MetadataRecord> result = new ArrayList<MetadataRecord>(); for (Object o : kids) { MetadataRecord mr = (MetadataRecord) o; if (uuids.contains(mr.getUUID())) { result.add(mr); } } return result; }
/** * Return all index file records that match the specified entity name * * @param indexName * @param entityName the name to match * @param isPartialName true if the entity name is a partially qualified * @return results * @throws Exception */ @Override protected Collection findChildRecords( final MetadataRecord parentRecord, final char childRecordType) throws Exception { CoreArgCheck.isNotNull(parentRecord); // find the eObject on the parent record EObject parentObj = (EObject) parentRecord.getEObject(); // if not preset look up by uuid if (parentObj == null) { String uuid = parentRecord.getUUID(); parentObj = lookupEObject(uuid); } if (parentObj != null) { SqlAspect sqlAspect = AspectManager.getSqlAspect(parentObj); if (sqlAspect instanceof SqlTableAspect) { SqlTableAspect tableAspect = (SqlTableAspect) sqlAspect; switch (childRecordType) { case IndexConstants.RECORD_TYPE.COLUMN: Collection columns = tableAspect.getColumns(parentObj); return findMetadataRecords(childRecordType, columns); case IndexConstants.RECORD_TYPE.FOREIGN_KEY: Collection foreignKeys = tableAspect.getForeignKeys(parentObj); return findMetadataRecords(childRecordType, foreignKeys); case IndexConstants.RECORD_TYPE.UNIQUE_KEY: Collection uniqueKeys = tableAspect.getUniqueKeys(parentObj); return findMetadataRecords(childRecordType, uniqueKeys); case IndexConstants.RECORD_TYPE.PRIMARY_KEY: EObject primaryKey = (EObject) tableAspect.getPrimaryKey(parentObj); MetadataRecord record = createMetadataRecord(childRecordType, primaryKey); if (record != null) { Collection records = new ArrayList(1); records.add(record); return records; } break; case IndexConstants.RECORD_TYPE.ACCESS_PATTERN: Collection accPtterns = tableAspect.getAccessPatterns(parentObj); return findMetadataRecords(childRecordType, accPtterns); case IndexConstants.RECORD_TYPE.INDEX: Collection indexes = tableAspect.getIndexes(parentObj); return findMetadataRecords(childRecordType, indexes); } } else if (sqlAspect instanceof SqlProcedureAspect) { SqlProcedureAspect procAspect = (SqlProcedureAspect) sqlAspect; switch (childRecordType) { case IndexConstants.RECORD_TYPE.CALLABLE_PARAMETER: Collection params = procAspect.getParameters(parentObj); return findMetadataRecords(childRecordType, params); case IndexConstants.RECORD_TYPE.RESULT_SET: EObject result = (EObject) procAspect.getResult(parentObj); MetadataRecord record = createMetadataRecord(childRecordType, result); if (record != null) { Collection records = new ArrayList(1); records.add(record); return records; } break; } } else if (sqlAspect instanceof SqlColumnSetAspect) { SqlColumnSetAspect colSetAspect = (SqlColumnSetAspect) sqlAspect; switch (childRecordType) { case IndexConstants.RECORD_TYPE.COLUMN: Collection column = colSetAspect.getColumns(parentObj); return findMetadataRecords(childRecordType, column); default: break; } } } return Collections.EMPTY_LIST; }