@Test public void getTranslatorPropertyDefinitions() throws Exception { HashSet<String> props = new HashSet<String>(); Collection<? extends PropertyDefinition> pds = admin.getTranslatorPropertyDefinitions("ws"); for (PropertyDefinition pd : pds) { props.add(pd.getName()); } assertTrue(props.contains("DefaultBinding")); assertTrue(props.contains("DefaultServiceMode")); assertTrue(props.contains("MaxDependentInPredicates")); for (PropertyDefinition pd : pds) { if (pd.getName().equals("DefaultBinding")) { assertEquals("java.lang.String", pd.getPropertyTypeClassName()); assertFalse(pd.isRequired()); assertEquals( "Contols what SOAP or HTTP type of invocation will be used if none is specified.", pd.getDescription()); assertEquals("Default Binding", pd.getDisplayName()); assertTrue(pd.isModifiable()); assertFalse(pd.isAdvanced()); assertFalse(pd.isMasked()); assertEquals("SOAP12", pd.getDefaultValue()); assertNotNull(pd.getAllowedValues()); } } }
/** * {@inheritDoc} * * @see * org.teiid.designer.vdb.connections.SourceHandler#getTranslatorDefinitions(java.lang.String) */ @Override public PropertyDefinition[] getTranslatorDefinitions(String translatorName) { if (StringUtilities.isEmpty(translatorName)) { throw new IllegalArgumentException(); } Server defaultServer = getDefaultServer(); if ((defaultServer != null) && defaultServer.isConnected()) { try { TeiidTranslator translator = defaultServer.getAdmin().getTranslator(translatorName); if (translator != null) { Collection<PropertyDefinition> props = new ArrayList<PropertyDefinition>(); for (org.teiid.adminapi.PropertyDefinition propDefn : translator.getPropertyDefinitions()) { TranslatorProperty prop = new TranslatorProperty(propDefn.getPropertyTypeClassName()); prop.advanced = propDefn.isAdvanced(); prop.description = propDefn.getDescription(); prop.displayName = propDefn.getDisplayName(); prop.id = propDefn.getName(); prop.masked = propDefn.isMasked(); prop.modifiable = propDefn.isModifiable(); prop.required = propDefn.isRequired(); prop.defaultValue = (propDefn.getDefaultValue() == null) ? StringUtilities.EMPTY_STRING : propDefn.getDefaultValue().toString(); if (propDefn.isConstrainedToAllowedValues()) { Collection values = propDefn.getAllowedValues(); prop.allowedValues = new String[values.size()]; int i = 0; for (Object value : values) { prop.allowedValues[i++] = value.toString(); } } else { // if boolean type turn into allowed values String type = propDefn.getPropertyTypeClassName(); if (Boolean.class.getName().equals(type) || Boolean.TYPE.getName().equals(type)) { prop.allowedValues = new String[] {Boolean.TRUE.toString(), Boolean.FALSE.toString()}; } } props.add(prop); } return props.toArray(new PropertyDefinition[props.size()]); } } catch (Exception e) { UTIL.log( IStatus.ERROR, e, UTIL.getString( "VdbSourceConnectionHandler.errorObtainingTranslatorProperties", //$NON-NLS-1$ translatorName, defaultServer.getHost())); } } return null; }