Package org.teiid.adminapi.impl

Examples of org.teiid.adminapi.impl.ModelMetaData


  }

  private boolean validateSources(ConnectorManagerRepository cmr, VDBMetaData deployment) {
    boolean valid = true;
    for(Model m:deployment.getModels()) {
      ModelMetaData model = (ModelMetaData)m;
      List<SourceMappingMetadata> mappings = model.getSourceMappings();
      for (SourceMappingMetadata mapping:mappings) {
        ConnectorManager cm = cmr.getConnectorManager(mapping.getName());
        String msg = cm.getStausMessage();
        if (msg != null && msg.length() > 0) {
          valid = false;
          model.addError(ModelMetaData.ValidationError.Severity.ERROR.name(), cm.getStausMessage());
          LogManager.logInfo(LogConstants.CTX_RUNTIME, cm.getStausMessage());
        }
      }
     
      // in the dynamic case the metadata may be still loading.
      if (!model.getErrors().isEmpty()) {
        valid = false;
      }
    }
    return valid;
  }
View Full Code Here


      LinkedList<Runnable> runnables = new LinkedList<Runnable>();
      synchronized (vdb) {
        ConnectorManagerRepository cmr = vdb.getAttachment(ConnectorManagerRepository.class);
       
        for (Model m:vdb.getModels()) {
          ModelMetaData model = (ModelMetaData)m;
          if (model.getErrors().isEmpty()) {
            continue;
          }
 
          String sourceName = getSourceName(resourceName, model, translator);
          if (sourceName == null) {
            continue;
          }
          ConnectorManager cm = cmr.getConnectorManager(sourceName);
          String status = cm.getStausMessage();
          if (status != null && status.length() > 0) {
            model.addError(ModelMetaData.ValidationError.Severity.ERROR.name(), status);
            LogManager.logInfo(LogConstants.CTX_RUNTIME, status);         
          } else {
            //get the pending metadata load
            Runnable r = model.removeAttachment(Runnable.class);
            if (r != null) {
              runnables.add(r);
            } else {
              model.clearErrors();
            }
          }
        }
 
        boolean valid = true;
        for (Model m:vdb.getModels()) {
          ModelMetaData model = (ModelMetaData)m;
          if (!model.getErrors().isEmpty()) {
            valid = false;
            break;
          }
        }
       
View Full Code Here

      if (vdb.isPreview()) {
        continue;
      }
      synchronized (vdb) {
        for (Model m:vdb.getModels()) {
          ModelMetaData model = (ModelMetaData)m;
         
          String sourceName = getSourceName(resourceName, model, translator);
          if (sourceName != null) {
            vdb.setStatus(VDB.Status.INACTIVE);
            String msg = null;
            if (translator) {
              msg = RuntimePlugin.Util.getString("translator_not_found", vdb.getName(), vdb.getVersion(), model.getSourceTranslatorName(sourceName)); //$NON-NLS-1$
            }
            else {
              msg = RuntimePlugin.Util.getString("datasource_not_found", vdb.getName(), vdb.getVersion(), model.getSourceTranslatorName(sourceName)); //$NON-NLS-1$
            }
            model.addError(ModelMetaData.ValidationError.Severity.ERROR.name(), msg);
            LogManager.logInfo(LogConstants.CTX_RUNTIME, msg);         
            LogManager.logInfo(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.getString("vdb_inactivated",vdb.getName(), vdb.getVersion())); //$NON-NLS-1$             
          }
        }
      }
View Full Code Here

   
    if (property.getName().equals("models")) { //$NON-NLS-1$
      List<ManagedObject> models = (List<ManagedObject>)MetaValueFactory.getInstance().unwrap(property.getValue());
      for(ManagedObject managedModel:models) {
        String modelName = ManagedUtil.getSimpleValue(managedModel, "name", String.class); //$NON-NLS-1$
        ModelMetaData model = vdb.getModel(modelName);
       
            ManagedProperty sourceMappings = managedModel.getProperty("sourceMappings");//$NON-NLS-1$
            if (sourceMappings != null){
                List<ManagedObject> mappings = (List<ManagedObject>)MetaValueFactory.getInstance().unwrap(sourceMappings.getValue());
                for (ManagedObject mo:mappings) {
                    String name = ManagedUtil.getSimpleValue(mo, "name", String.class);//$NON-NLS-1$
                    String jndiName = ManagedUtil.getSimpleValue(mo, "connectionJndiName", String.class);//$NON-NLS-1$
                    String translatorName = ManagedUtil.getSimpleValue(mo, "translatorName", String.class);//$NON-NLS-1$
                    model.addSourceMapping(name, translatorName, jndiName);
                }
            }       
      }           
    }
    else if (property.getName().equals("JAXBProperties")) { //$NON-NLS-1$
View Full Code Here

    if(!this.multiSourceModels.contains(modelName)) {
            return accessNode;
        }
       
    VDBMetaData vdb = workContext.getVDB();
        ModelMetaData model = vdb.getModel(modelName);
        List<AccessNode> accessNodes = new ArrayList<AccessNode>();
       
        boolean hasOutParams = false;
        if (accessNode.getCommand() instanceof StoredProcedure) {
          StoredProcedure sp = (StoredProcedure)accessNode.getCommand();
          hasOutParams = sp.returnParameters() && sp.getProjectedSymbols().size() > sp.getResultSetColumns().size();
        }
       
        for(String sourceName:model.getSourceNames()) {
           
            // Create a new cloned version of the access node and set it's model name to be the bindingUUID
            AccessNode instanceNode = (AccessNode) accessNode.clone();
            instanceNode.setID(getID());
            instanceNode.setConnectorBindingId(sourceName);
View Full Code Here

    
        Set<String> multiSourceModels = vdb.getMultiSourceModelNames();
        for (String model:multiSourceModels) {
            char sourceID = 'a';
            // by default every model has one binding associated, but for multi-source there were none assigned.
            ModelMetaData m = vdb.getModel(model);
            int x = m.getSourceNames().size();
            for(int i=x; i<sourceCount; i++, sourceID++) {
               m.addSourceMapping("" + sourceID, "translator"null); //$NON-NLS-1$ //$NON-NLS-2$
            }
        }
       
        MultiSourceMetadataWrapper wrapper = new MultiSourceMetadataWrapper(metadata, multiSourceModels);
        AnalysisRecord analysis = new AnalysisRecord(false, DEBUG);
View Full Code Here

      
        ArrayList<String> bindings = new ArrayList<String>();
        bindings.add(modelName);
       
        VDBMetaData vdb = Mockito.mock(VDBMetaData.class);
        ModelMetaData model = Mockito.mock(ModelMetaData.class);
        Mockito.stub(vdb.getModel(modelName)).toReturn(model);
        Mockito.stub(model.getSourceNames()).toReturn(bindings);
       
        BasicSourceCapabilities basicSourceCapabilities = new BasicSourceCapabilities();
        basicSourceCapabilities.setFunctionSupport(functionName, true);

        ConnectorManagerRepository repo = Mockito.mock(ConnectorManagerRepository.class);
View Full Code Here

    vdb.setName("myVDB");
    vdb.setDescription("vdb description");
    vdb.setVersion(1);
    vdb.addProperty("vdb-property", "vdb-value")
   
    ModelMetaData modelOne = new ModelMetaData();
    modelOne.setName("model-one");
    modelOne.addSourceMapping("s1", "translator", "java:mybinding")
    modelOne.setModelType(Model.Type.PHYSICAL);
    modelOne.addProperty("model-prop", "model-value")
    modelOne.addProperty("model-prop", "model-value-override")
    modelOne.setVisible(false);
    modelOne.addError("ERROR", "There is an error in VDB")
    modelOne.setDescription("model description");
   
    vdb.addModel(modelOne);
   
    ModelMetaData modelTwo = new ModelMetaData();
    modelTwo.setName("model-two");
    modelTwo.addSourceMapping("s1", "translator", "java:binding-one")
    modelTwo.addSourceMapping("s2", "translator", "java:binding-two")
    modelTwo.setModelType(Model.Type.VIRTUAL);
    modelTwo.addProperty("model-prop", "model-value")
   
    vdb.addModel(modelTwo);
   
    TranslatorMetaData t1 = new TranslatorMetaData();
    t1.setName("oracleOverride");
    t1.setType("oracle");
    t1.addProperty("my-property", "my-value");
    List<Translator> list = new ArrayList<Translator>();
    list.add(t1);
    vdb.setOverrideTranslators(list);
   
    DataPolicyMetadata roleOne = new DataPolicyMetadata();
    roleOne.setName("roleOne");
    roleOne.setDescription("roleOne described");
   
    PermissionMetaData perm1 = new PermissionMetaData();
    perm1.setResourceName("myTable.T1");
    perm1.setAllowRead(true);
    roleOne.addPermission(perm1);
   
    PermissionMetaData perm2 = new PermissionMetaData();
    perm2.setResourceName("myTable.T2");
    perm2.setAllowRead(false);
    perm2.setAllowDelete(true);
    roleOne.addPermission(perm2);
   
    roleOne.setMappedRoleNames(Arrays.asList("ROLE1", "ROLE2"))
   
    vdb.addDataPolicy(roleOne);
   
    // convert to managed object and build the VDB out of MO
    ManagedObjectFactory mof = ManagedObjectFactoryBuilder.create();
    ManagedObject mo = mof.initManagedObject(vdb, null, null);
    vdb = AdminObjectBuilder.buildAO(mo, VDBMetaData.class);
   
    assertEquals("myVDB", vdb.getName());
    assertEquals("vdb description", vdb.getDescription());
    assertEquals(1, vdb.getVersion());
    assertEquals("vdb-value", vdb.getPropertyValue("vdb-property"))
   
    assertNotNull(vdb.getModel("model-one"));
    assertNotNull(vdb.getModel("model-two"));
    assertNull(vdb.getModel("model-unknown"));
   
    modelOne = vdb.getModel("model-one");
    assertEquals("model-one", modelOne.getName());
    assertEquals("s1", modelOne.getSourceNames().get(0));
    assertEquals(Model.Type.PHYSICAL, modelOne.getModelType());
    assertEquals("model-value-override", modelOne.getPropertyValue("model-prop"))
    assertFalse(modelOne.isVisible());
    assertEquals("model description", modelOne.getDescription());
   
    modelTwo = vdb.getModel("model-two");
    assertEquals("model-two", modelTwo.getName());
    assertTrue(modelTwo.getSourceNames().contains("s1"));
    assertTrue(modelTwo.getSourceNames().contains("s2"));
    assertEquals(Model.Type.VIRTUAL, modelTwo.getModelType()); // this is not persisted in the XML
    assertEquals("model-value", modelTwo.getPropertyValue("model-prop"))
   
   
    assertTrue(vdb.getValidityErrors().contains("There is an error in VDB"));
   
    List<Translator> translators = vdb.getOverrideTranslators();
View Full Code Here

   
    return new TransformationMetadata(vdb, cms, resources, FakeMetadataFactory.SFM.getSystemFunctions(), null);
  }
 
  ModelMetaData buildModel(String name) {
    ModelMetaData model = new ModelMetaData();
    model.setName(name);
    model.setModelType(Model.Type.PHYSICAL);
    model.setVisible(true);
    return model;
  }
View Full Code Here

   
    VDBMetaData vdb = new VDBMetaData();
    vdb.setName("foo");
    vdb.setVersion(1);
   
    ModelMetaData model = new ModelMetaData();
    model.setName("x1");
    vdb.addModel(model);
   
    ModelMetaData model2 = new ModelMetaData();
    model2.setName("x");
    model2.setVisible(true);
    vdb.addModel(model2);   

    TransformationMetadata tm = new TransformationMetadata(vdb, cms, null, FakeMetadataFactory.SFM.getSystemFunctions(), null);
    Collection result = tm.getGroupsForPartialName("y"); //$NON-NLS-1$
    assertEquals(2, result.size());
View Full Code Here

TOP

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

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.