DefinitionRegistryService
Code IndexAdd Codota to your IDE (free)

Best Java code snippets using org.talend.daikon.definition.service.DefinitionRegistryService (Showing top 20 results out of 315)

origin: Talend/components

private void updateProperties() {
  String selectedFileFormatDefinitionStr = format.getValue();
  if (!StringUtils.isEmpty(selectedFileFormatDefinitionStr)
      && !StringUtils.equals(previousFormatValue, selectedFileFormatDefinitionStr)) {
    V props = referenceMemento.get(selectedFileFormatDefinitionStr);
    if (props == null) {
      Definition<V> fileFormatDefinition = getDefinitionRegistry().getDefinitionsMapByType(getDefinitionClass())
          .get(selectedFileFormatDefinitionStr);
      props = getDefinitionRegistry().createProperties(fileFormatDefinition, FORMAT_PROPERTIES_NAME);
      referenceMemento.put(selectedFileFormatDefinitionStr, props);
    }
    formatProperties = props;
  } else if (!StringUtils.isEmpty(selectedFileFormatDefinitionStr)
      && StringUtils.equals(previousFormatValue, selectedFileFormatDefinitionStr)) {
    // After deserialization we already have formatProperties, but we need to put them to referenceMemento
    referenceMemento.put(selectedFileFormatDefinitionStr, (V) formatProperties);
  }
  previousFormatValue = selectedFileFormatDefinitionStr;
}
origin: Talend/components

public <T extends Definition> T getFirstDefinitionFromProperties(Properties properties) {
  Iterable<Definition> definitionForPropertiesType = definitionServiceDelegate
      .getDefinitionForPropertiesType(properties.getClass());
  Validate.isTrue(definitionForPropertiesType.iterator().hasNext(),
      "Could not find a definition for the datastore properties %s", properties.getClass().getName());
  T datastoreDefinition = (T) definitionForPropertiesType.iterator().next();
  return datastoreDefinition;
}
origin: Talend/components

public Definition<?> getDefinition(String definitionName) {
  return definitionServiceDelegate.getDefinitionsMapByType(Definition.class).get(definitionName);
}
origin: Talend/components

when(delegate.getDefinitionsMapByType(DatastoreDefinition.class)) //
    .thenReturn(datastoresMap);
when(delegate.getDefinitionsMapByType(DatasetDefinition.class)) //
    .thenReturn(datasetMap);
runtimablesMap.putAll(datastoresMap);
runtimablesMap.putAll(datasetMap);
when(delegate.getDefinitionsMapByType(Definition.class)) //
    .thenReturn(runtimablesMap);
when(delegate.getDefinitionsMapByType(Definition.class)) //
    .thenReturn(runtimablesMap);
when(delegate.getDefinitionForPropertiesType(MockDatasetProperties.class)).thenReturn(singletonList(datasetDefinition));
when(delegate.getDefinitionForPropertiesType(MockDatastoreProperties.class))
    .thenReturn(singletonList(datastoreDefinition));
when(delegate.createProperties(any(Definition.class), anyString())).thenAnswer(i -> {
  Properties properties = PropertiesImpl.createNewInstance(
      ((Definition<Properties>) i.getArguments()[0]).getPropertiesClass(), (String) i.getArguments()[1]);
origin: Talend/components

@Override
public String getProperties(String definitionName, String formName) {
  notNull(definitionName, "Connection name cannot be null.");
  final Definition<?> definition = propertiesHelpers.getDefinition(definitionName);
  notNull(definition, "Could not find connection definition of name %s", definitionName);
  log.debug("Found connection definition {} for {}", definition, definitionName);
  return jsonSerializationHelper.toJson(
      definitionServiceDelegate.createProperties(definition, definitionName + " properties"), formName, definitionName);
}
origin: Talend/components

public <T extends Definition> T getDefinition(Class<T> clazz, String definitionName) {
  return definitionServiceDelegate.getDefinitionsMapByType(clazz).get(definitionName);
}
origin: Talend/components

@Test
public void testCreateNewPropertiesWithInjected() {
  DefinitionRegistryService registry = new DefinitionRegistry();
  TestInjectComponentDefinition def = new TestInjectComponentDefinition();
  TestInjectComponentProperties testProps = (TestInjectComponentProperties) registry.createProperties(def, "testProps");
  assertThat(testProps.getDefinitionRegistry(), equalTo(registry));
}
origin: org.talend.components/components-common

protected Map<String, ? extends Definition<V>> getPossibleFormatValues() {
  DefinitionRegistryService registry = getDefinitionRegistry();
  if (registry == null) {
    return Collections.emptyMap();
  }
  return registry.getDefinitionsMapByType(getDefinitionClass());
}
origin: org.talend.components/components-common

private void updateProperties() {
  String selectedFileFormatDefinitionStr = format.getValue();
  if (!StringUtils.isEmpty(selectedFileFormatDefinitionStr)
      && !StringUtils.equals(previousFormatValue, selectedFileFormatDefinitionStr)) {
    V props = referenceMemento.get(selectedFileFormatDefinitionStr);
    if (props == null) {
      Definition<V> fileFormatDefinition = getDefinitionRegistry().getDefinitionsMapByType(getDefinitionClass())
          .get(selectedFileFormatDefinitionStr);
      props = getDefinitionRegistry().createProperties(fileFormatDefinition, FORMAT_PROPERTIES_NAME);
      referenceMemento.put(selectedFileFormatDefinitionStr, props);
    }
    formatProperties = props;
  } else if (!StringUtils.isEmpty(selectedFileFormatDefinitionStr)
      && StringUtils.equals(previousFormatValue, selectedFileFormatDefinitionStr)) {
    // After deserialization we already have formatProperties, but we need to put them to referenceMemento
    referenceMemento.put(selectedFileFormatDefinitionStr, (V) formatProperties);
  }
  previousFormatValue = selectedFileFormatDefinitionStr;
}
origin: Talend/components

@Test
public void testCreateNewPropertiesWithNestedInjected() {
  DefinitionRegistryService registry = new DefinitionRegistry();
  TestNestedInjectComponentDefinition def = new TestNestedInjectComponentDefinition();
  TestNestedInjectComponentProperties testProps = (TestNestedInjectComponentProperties) registry.createProperties(def,
      "testProps");
  assertThat(testProps.getNestedProperties().getDefinitionRegistry(), equalTo(registry));
}
origin: Talend/components

/**
 * Creates a ui-spec representation of the properties including json-schema, json-ui and json-data
 *
 * @param formName name of the wanted form.
 * @param properties instance of the properties to serialize.
 * @return json string in ui-specs representation of the data.
 */
public String toJson(String formName, Properties properties) {
  Iterable<Definition> definitionForPropertiesType = definitionRegistry .getDefinitionForPropertiesType(properties.getClass());
  if (!definitionForPropertiesType.iterator().hasNext()) {
    // did not find any definition for the given properties
    throw TalendRuntimeException.build(CommonErrorCodes.UNREGISTERED_DEFINITION).set(properties.getClass().getName());
  }
  // else we got definition so we take the first one.
  return JsonSchemaUtil.toJson(properties, formName, definitionForPropertiesType.iterator().next().getName());
}
origin: Talend/components

protected Map<String, ? extends Definition<V>> getPossibleFormatValues() {
  DefinitionRegistryService registry = getDefinitionRegistry();
  if (registry == null) {
    return Collections.emptyMap();
  }
  return registry.getDefinitionsMapByType(getDefinitionClass());
}
origin: org.talend.daikon/daikon

/**
 * returns a Properties instance if any found according to the json description and the registry.
 * The returned properties has been initialized (call to {@link Properties#init()}.
 */
static Properties fromJsonNode(DefinitionRegistryService defRegistryService, JsonNode jsonNode) throws NoSuchMethodException,
    IOException, InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException {
  JsonNode defNameNode = jsonNode.get(JsonSchemaConstants.DEFINITION_NAME_JSON_METADATA);
  if (defNameNode == null) {
    throw TalendRuntimeException.build(CommonErrorCodes.UNABLE_TO_PARSE_JSON).create();
  } // else we got one definition so try to use it
  Definition<?> definition = defRegistryService.getDefinitionsMapByType(Definition.class).get(defNameNode.asText());
  if (definition == null) {// we are trying to use a definition that is not registered
    throw TalendRuntimeException.build(CommonErrorCodes.UNREGISTERED_DEFINITION).set(defNameNode.asText());
  } // else we got a definition so let's use it to create the instance.
  return fromJson(jsonNode, (defRegistryService.createProperties(definition, "root")).init());
}
origin: org.talend.daikon/daikon

/**
 * resolve the referenced properties between a group of properties. And also may call the
 * after<ReferecenProperties.getName()> callback if any and if callAfterCallback is true
 * 
 * @param properties list of all references to resolve
 * @param definitionRegistry used to find the definitions compatible with current properties
 */
public static void resolveReferenceProperties(Iterable<? extends Properties> properties,
    DefinitionRegistryService definitionRegistry, boolean callAfterCallback) {
  // construct the definitionName and Properties map
  Map<String, Properties> def2PropsMap = new HashMap<>();
  for (Properties prop : properties) {
    // look for the definition associated with the properties
    Iterable<Definition> allDefs = definitionRegistry.getDefinitionForPropertiesType(prop.getClass());
    for (Definition def : allDefs) {
      def2PropsMap.put(def.getName(), prop);
    }
  }
  resolveReferenceProperties(def2PropsMap, callAfterCallback);
}
origin: Talend/components

/**
 * Return components that match the given typology and/or execution engine.
 *
 * @param typology the wanted typology.
 * @param executionEngine the wanted execution engine.
 * @return the list of all definitions that match the wanted typology.
 * @returnWrapped java.lang.Iterable<org.talend.components.service.rest.dto.DefinitionDTO>
 */
@Override
public List<DefinitionDTO> listComponentDefinitions(ConnectorTypology typology, ExecutionEngine executionEngine) {
  final Collection<ComponentDefinition> definitions = //
      definitionServiceDelegate.getDefinitionsMapByType(ComponentDefinition.class).values();
  Stream<ComponentDefinition> stream = definitions.stream();
  if (typology != null) {
    stream = stream.filter(c -> c.getSupportedConnectorTopologies().contains(typology.getTopology()));
  }
  if (executionEngine != null) {
    stream = stream.filter(c -> c.isSupportingExecutionEngines(executionEngine));
  }
  final List<DefinitionDTO> result = stream //
      .map(DefinitionDTO::new) //
      .collect(Collectors.toList());
  logger.debug("found {} component definitions for typology {}", result.size(), typology);
  return result;
}
origin: Talend/components

definitionServiceDelegate.getDefinitionsMapByType(type.getTargetClass()).values();
origin: Talend/components

@Test
@Ignore
public void listDataStoreDefinitions() throws Exception {
  ArrayList<DatastoreDefinition> value = new ArrayList<>();
  when(defRegistryDelegate.getDefinitionsMapByType(DatastoreDefinition.class).values()).thenReturn(value);
  //Iterable<DefinitionDTO> datastoreDefinitions = dataStoreController.listDataStoreDefinitions(
   //      DefinitionType.DATA_STORE);
  // assertEquals(value, datastoreDefinitions);
  // verify(componentServiceDelegate).getDefinitionsByType(DatastoreDefinition.class);
}
origin: Talend/components

/**
 * check that all Components and Wizards have theirs images properly set.
 * 
 * @param componentService service to get the components to be checked.
 * 
 */
public static void assertAllComponentImagesAreSet(DefinitionRegistryService definitionRegistry) {
  // check components
  Collection<ComponentDefinition> allComponents = definitionRegistry.getDefinitionsMapByType(ComponentDefinition.class)
      .values();
  for (ComponentDefinition compDef : allComponents) {
    assertComponentImagesAreSet(compDef);
  }
  // check wizards
  Collection<ComponentWizardDefinition> allWizards = definitionRegistry
      .getDefinitionsMapByType(ComponentWizardDefinition.class).values();
  for (ComponentWizardDefinition wizDef : allWizards) {
    assertWizardImagesAreSet(wizDef);
  }
}
origin: Talend/components

@Test
@Ignore
public void getDatastoreDefinition() throws Exception {
  // Given
  ArrayList<DatastoreDefinition> definitions = new ArrayList<>();
  DatastoreDefinition dsd1 = mock(DatastoreDefinition.class);
  when(dsd1.getName()).thenReturn("toto");
  definitions.add(dsd1);
  DatastoreDefinition dsd2 = mock(DatastoreDefinition.class);
  String datastoreName = "datastore name";
  when(dsd2.getName()).thenReturn(datastoreName);
  definitions.add(dsd2);
  when(defRegistryDelegate.getDefinitionsMapByType(DatastoreDefinition.class).values()).thenReturn(definitions);
  // When
  // DatastoreDefinition datastoreDefinition = dataStoreController.getDataStoreProperties(datastoreName);
  //
  // // Then
  // assertEquals(dsd2, datastoreDefinition);
  // verify(componentServiceDelegate, times(1)).getDefinitionsByType(DatastoreDefinition.class);
  // verify(dsd1, times(1)).getName();
  // verify(dsd2, times(1)).getName();
}
origin: Talend/components

/**
 * check all properties of a component for i18n, check form i18n, check ComponentProperties title is i18n
 * 
 * @param componentService where to get all the components
 * @param errorCollector used to collect all errors at once. @see
 *            <a href="http://junit.org/apidocs/org/junit/rules/ErrorCollector.html">ErrorCollector</a>
 */
static public void assertReturnProperties18nAreSet(DefinitionRegistryService definitionRegistry,
    ErrorCollector errorCollector) {
  Collection<ComponentDefinition> allComponents = definitionRegistry.getDefinitionsMapByType(ComponentDefinition.class)
      .values();
  for (ComponentDefinition cd : allComponents) {
    // check return properties i18n
    checkAllPropertyI18n(cd.getReturnProperties(), cd, errorCollector);
  }
}
org.talend.daikon.definition.serviceDefinitionRegistryService

Javadoc

The service should handle Definition and guarantees that only one instance is registered with a unique name ( Definition#getName()

Most used methods

  • createProperties
    creates the Properties instance related to the Definition, the returned properties has also been ini
  • getDefinitionsMapByType
    Get the map of all Definition that implement a specific interface using the name as the map key.
  • getDefinitionForPropertiesType

Popular in Java

  • Running tasks concurrently on multiple threads
  • getExternalFilesDir (Context)
  • getSharedPreferences (Context)
  • getSupportFragmentManager (FragmentActivity)
    Return the FragmentManager for interacting with fragments associated with this activity.
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • BoxLayout (javax.swing)
  • JFileChooser (javax.swing)
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a

For IntelliJ IDEA,
Android Studio or Eclipse

  • Search for JavaScript code betaCodota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutBlogContact Us
  • Plugin user guideTerms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)