/*
   * @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;
  }
  /**
   * Create additional commands for copying the supplied additional "related" objects, and
   * add-and-execute them (via the {@link PasteFromClipboard#appendAndExecute(}).
   *
   * @param additionalObjs the original "related" objects that are to be copied and added to the
   *     correct location; never null
   * @param targetContents the content helper for the Resource in which the object is being copied
   *     and pasted; never null
   * @return the subset of <code>additionalObjs</code> that were not handled by this implementation;
   *     never null
   */
  protected Collection doCreateAdditionalCommands(
      final Collection additionalObjs, final ModelContents targetContents) {
    if (additionalObjs.isEmpty()) {
      return additionalObjs;
    }

    // Find all of the annotations and transformations ...
    final Set annotations = new HashSet();
    final Set transformations = new HashSet();
    final Set mappingClassSets = new HashSet();
    final List remaining = new LinkedList();
    final Iterator iter = additionalObjs.iterator();
    while (iter.hasNext()) {
      final Object additionalObj = iter.next();
      if (additionalObj instanceof Annotation) {
        annotations.add(additionalObj);
      } else if (additionalObj instanceof TransformationMappingRoot) {
        transformations.add(additionalObj);
      } else if (additionalObj instanceof MappingClassSet) {
        mappingClassSets.add(additionalObj);
      } else {
        remaining.add(additionalObj);
      }
    }

    // Create the copy command for all of the annotations ...
    if (annotations.size() != 0) {
      // Note:  container will probably be null due to changes in the following underlying method
      // call.
      // This is due to the targetContents' Resource == NULL (see
      // ModelResourceContainerFactory.getAnnotationContainer());
      AnnotationContainer container = targetContents.getAnnotationContainer(true);
      if (container == null) {
        // it's null, so we'll new one up via the CoreFactory....
        container = CoreFactory.eINSTANCE.createAnnotationContainer();
        // since one wasn't found, we need to create a temporary one and add to contents
        targetContents.getAllRootEObjects().add(container);
      }

      final EStructuralFeature feature = CorePackage.eINSTANCE.getAnnotationContainer_Annotations();
      copyAndAdd(annotations, container, feature);
    }

    // Create the copy command for all of the mapping class sets ...
    if (mappingClassSets.size() != 0) {
      // Note:  container will probably be null due to changes in the following underlying method
      // call.
      // This is due to the targetContents' Resource == NULL (see
      // ModelResourceContainerFactory.getMappingClassSetContainer());
      MappingClassSetContainer container = targetContents.getMappingClassSetContainer(true);
      if (container == null) {
        // it's null, so we'll new one up via the TransformationFactory....
        container = TransformationFactory.eINSTANCE.createMappingClassSetContainer();
        // since one wasn't found, we need to create a temporary one and add to contents
        targetContents.getAllRootEObjects().add(container);
      }

      final EStructuralFeature feature =
          TransformationPackage.eINSTANCE.getMappingClassSetContainer_MappingClassSets();
      copyAndAdd(mappingClassSets, container, feature);
    }

    // Create the copy command for all of the transformations ...
    if (transformations.size() != 0) {
      // Note:  container will probably be null due to changes in the following underlying method
      // call.
      // This is due to the targetContents' Resource == NULL (see
      // ModelResourceContainerFactory.getMappingClassSetContainer());
      TransformationContainer container = targetContents.getTransformationContainer(true);
      if (container == null) {
        // it's null, so we'll new one up via the TransformationFactory....
        container = TransformationFactory.eINSTANCE.createTransformationContainer();
        // since one wasn't found, we need to create a temporary one and add to contents
        targetContents.getAllRootEObjects().add(container);
      }

      final EStructuralFeature feature =
          TransformationPackage.eINSTANCE.getTransformationContainer_TransformationMappings();
      copyAndAdd(transformations, container, feature);
    }
    return null;
  }