ManagedComponent mc = getVDBManagedComponent(vdbName, vdbVersion);
if (mc == null) {
throw new AdminProcessingException(IntegrationPlugin.Util.getString("vdb_not_found", vdbName, vdbVersion)); //$NON-NLS-1$
}
ManagedProperty mp = mc.getProperty("models");//$NON-NLS-1$
List<ManagedObject> models = (List<ManagedObject>)MetaValueFactory.getInstance().unwrap(mp.getValue());
ManagedObject managedModel = null;
if (models != null && !models.isEmpty()) {
for(ManagedObject mo:models) {
String name = ManagedUtil.getSimpleValue(mo, "name", String.class); //$NON-NLS-1$
if (modelName.equals(name)) {
managedModel = mo;
}
}
}
if (managedModel == null) {
throw new AdminProcessingException(IntegrationPlugin.Util.getString("model_not_found", modelName, vdbName, vdbVersion)); //$NON-NLS-1$
}
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 sName = ManagedUtil.getSimpleValue(mo, "name", String.class);//$NON-NLS-1$
if (sName.equals(sourceName)) {
ManagedProperty translatorProperty = mo.getProperty("translatorName"); //$NON-NLS-1$
if (translatorProperty == null) {
translatorProperty = new WritethroughManagedPropertyImpl(mo, new DefaultFieldsImpl("translatorName")); //$NON-NLS-1$
}
translatorProperty.setValue(ManagedUtil.wrap(SimpleMetaType.STRING, translatorName));
// set the jndi name for the ds.
ManagedProperty jndiProperty = mo.getProperty("connectionJndiName"); //$NON-NLS-1$
if (jndiProperty == null) {
jndiProperty = new WritethroughManagedPropertyImpl(mo, new DefaultFieldsImpl("connectionJndiName")); //$NON-NLS-1$
}
jndiProperty.setValue(ManagedUtil.wrap(SimpleMetaType.STRING, dsName));
}
}
} else {
//TODO: this can be in the default situation when no source mappings are specified
throw new AdminProcessingException(IntegrationPlugin.Util.getString("sourcename_not_found", sourceName, vdbName, vdbVersion, modelName)); //$NON-NLS-1$