Package org.teiid.adminapi.impl

Examples of org.teiid.adminapi.impl.TranslatorMetaData


    Collection<Object> group = unit.getAttachments().values();

    for (Object anObj : group) {
      if (anObj instanceof TranslatorMetaData) {
        TranslatorMetaData data = (TranslatorMetaData)anObj;
        String translatorName = data.getName();
        if (translatorName == null) {
          throw new DeploymentException(RuntimePlugin.Util.getString("name_not_found", unit.getName())); //$NON-NLS-1$
        }
       
        // fill with default properties for the tooling to see the properties
        Properties props = TranslatorUtil.getTranslatorPropertiesAsProperties(data.getExecutionFactoryClass());
        data.setProperties(props);
        data.addProperty(TranslatorMetaData.EXECUTION_FACTORY_CLASS, data.getExecutionFactoryClass().getName());
       
              this.translatorRepository.addTranslatorMetadata(translatorName, data);
              LogManager.logInfo(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.getString("translator_added", translatorName)); //$NON-NLS-1$
              this.vdbChecker.translatorAdded(translatorName);
      }
View Full Code Here


   
    Collection<Object> group = unit.getAttachments().values();

    for (Object anObj : group) {
      if (anObj instanceof TranslatorMetaData) {
        TranslatorMetaData data = (TranslatorMetaData)anObj;
        String translatorName = data.getName();
        if (this.translatorRepository != null) {
          this.translatorRepository.removeTranslatorMetadata(translatorName);
          LogManager.logInfo(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.getString("translator_removed", translatorName)); //$NON-NLS-1$
          this.vdbChecker.translatorRemoved(translatorName);
        }
View Full Code Here

  public void build(DeploymentUnit unit, Set<String> attachmentNames, Map<String, ManagedObject> managedObjects) throws DeploymentException {
    Collection<Object> group = unit.getAttachments().values();

    for (Object anObj : group) {
      if (anObj instanceof TranslatorMetaData) {
        TranslatorMetaData data = (TranslatorMetaData)anObj;
       
        ManagedObject mo = this.mof.initManagedObject(data, TranslatorMetaData.class, data.getName(),data.getName());
        if (mo == null) {
          throw new DeploymentException("could not create managed object"); //$NON-NLS-1$
        }
        managedObjects.put(mo.getName(), mo);
       
View Full Code Here

      String name = bean.name();
      if (name == null) {
        throw new IllegalArgumentException("Null Translator name: " + clazz); //$NON-NLS-1$
      }
     
      TranslatorMetaData data = new TranslatorMetaData();
      data.setName(bean.name());
      data.setExecutionFactoryClass(clazz);
      data.setDescription(bean.description());

      return data;
    }
View Full Code Here

    TranslatorMetaDataGroup group = new TranslatorMetaDataGroup();
   
    // The management framework, will update the attachment the managed property value changes.
    // that way the translator is configured.
    TranslatorMetaData translator = new TranslatorMetaData();
        this.mof.setInstanceClassFactory(TranslatorMetaData.class, new TranslatorMetadataICF(this.mof));
        ManagedObject mo = mof.initManagedObject(translator, "teiid", "translator"); //$NON-NLS-1$ //$NON-NLS-2$   

    for (ManagedProperty mp : values.getProperties().values()) {
      ManagedProperty dsProp = mo.getProperty(mp.getName());
View Full Code Here

  }

  @Override
  protected ManagedObject getComponent(Object attachment, PersistedComponent component, boolean create) {
    TranslatorMetaDataGroup deployment = (TranslatorMetaDataGroup) attachment;
    TranslatorMetaData data = null;
    if (deployment.getTranslators() != null && !deployment.getTranslators().isEmpty()) {
      for (TranslatorMetaData md : deployment.getTranslators()) {
        if (md.getName().equals(component.getOriginalName())) {
          data = md;
          break;
View Full Code Here

    }
  }

  @Override
  protected void setComponentName(PersistedComponent component, ManagedObject mo) {
    TranslatorMetaData metadata = (TranslatorMetaData)mo.getAttachment();
    component.setName(metadata.getName());
  }
View Full Code Here

@SuppressWarnings("nls")
public class TestTranslatorUtil {

  @Test
  public void testBuildExecutionFactory() throws Exception {
    TranslatorMetaData tm = new TranslatorMetaData();
   
    tm.addProperty("MyProperty", "correctly-assigned");
    tm.setExecutionFactoryClass(MyTranslator.class);
   
    MyTranslator my = (MyTranslator)TranslatorUtil.buildExecutionFactory(tm);
   
    assertEquals("correctly-assigned", my.getMyProperty());
  }
View Full Code Here

   
    assertEquals("correctly-assigned", my.getMyProperty());
  }
 
  @Test public void testBuildExecutionFactoryCaseInsensitive() throws Exception {
    TranslatorMetaData tm = new TranslatorMetaData();
   
    tm.addProperty("myproperty", "correctly-assigned");
    tm.setExecutionFactoryClass(MyTranslator.class);
   
    MyTranslator my = (MyTranslator)TranslatorUtil.buildExecutionFactory(tm);
   
    assertEquals("correctly-assigned", my.getMyProperty());
  }
View Full Code Here

  @Test
  public void testFormat() throws Exception {
   
    TranslatorMetaDataGroup group = new TranslatorMetaDataGroup();
    TranslatorMetaData tm = new TranslatorMetaData();
    group.translators.add(tm);
   
    tm.setExecutionFactoryClass(ExecutionFactory.class);
    tm.setName("Oracle");
    tm.setDescription("desc");
    tm.addProperty("ExtensionTranslationClassName", "org.teiid.translator.jdbc.oracle.OracleSQLTranslator");
   
    JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {TranslatorMetaDataGroup.class});
    Marshaller marshell = jc.createMarshaller();
    marshell.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,new Boolean(true));
   
    StringWriter sw = new StringWriter();
    marshell.marshal(group, sw);
       
    System.out.println(sw.toString());   
   
    Unmarshaller un = jc.createUnmarshaller();
    group = (TranslatorMetaDataGroup)un.unmarshal(new StringReader(sw.toString()));
   
    tm = group.getTranslators().get(0);
   
    assertEquals("Oracle", tm.getName());
    assertEquals("desc", tm.getDescription());
    assertEquals(ExecutionFactory.class.getName(), tm.getPropertyValue(Translator.EXECUTION_FACTORY_CLASS));
    assertEquals("org.teiid.translator.jdbc.oracle.OracleSQLTranslator", tm.getPropertyValue("ExtensionTranslationClassName"));
   
  }
View Full Code Here

TOP

Related Classes of org.teiid.adminapi.impl.TranslatorMetaData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.