Compare commits

...

1 Commits

Author SHA1 Message Date
jean-Philippe
c1d49ea8b1 fix the nullpointer repetitives at startup 2019-05-28 15:48:20 +02:00
2 changed files with 36 additions and 26 deletions

View File

@@ -9,4 +9,8 @@
</parent>
<artifactId>org.talend.repository.generic</artifactId>
<packaging>eclipse-plugin</packaging>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
</project>

View File

@@ -32,6 +32,7 @@ import org.talend.components.api.properties.ComponentProperties;
import org.talend.components.api.wizard.ComponentWizard;
import org.talend.components.api.wizard.ComponentWizardDefinition;
import org.talend.components.api.wizard.WizardImageType;
import org.talend.components.api.service.ComponentService;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.model.metadata.IMetadataTable;
import org.talend.core.model.metadata.builder.connection.Connection;
@@ -79,30 +80,33 @@ public class GenericWizardService implements IGenericWizardService {
@Override
public List<RepositoryNode> createNodesFromComponentService(RepositoryNode curParentNode) {
List<RepositoryNode> repNodes = new ArrayList<>();
Set<ComponentWizardDefinition> wizardDefinitions = internalService.getComponentService().getTopLevelComponentWizards();
for (ComponentWizardDefinition wizardDefinition : wizardDefinitions) {
String name = wizardDefinition.getName();
String displayName = wizardDefinition.getDisplayName();
String folder = "metadata/" + name; //$NON-NLS-1$
int ordinal = 100;
ERepositoryObjectType repositoryType = internalService.createRepositoryType(name, displayName, name, folder, ordinal);
if (curParentNode == null && "JDBC".equals(name)) { //$NON-NLS-1$
Class<ComponentProperties> jdbcClass = ReflectionUtils.getClass(
"org.talend.components.jdbc.wizard.JDBCConnectionWizardProperties",
wizardDefinition.getClass().getClassLoader());
if (jdbcClass != null && wizardDefinition.supportsProperties(jdbcClass)) {
IGenericDBService dbService = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericDBService.class)) {
dbService = (IGenericDBService) GlobalServiceRegister.getDefault().getService(IGenericDBService.class);
}
if (dbService != null) {
dbService.getExtraTypes().add(repositoryType);
ComponentService componentService = internalService.getComponentService();
if (componentService!=null) {
Set<ComponentWizardDefinition> wizardDefinitions = componentService.getTopLevelComponentWizards();
for (ComponentWizardDefinition wizardDefinition : wizardDefinitions) {
String name = wizardDefinition.getName();
String displayName = wizardDefinition.getDisplayName();
String folder = "metadata/" + name; //$NON-NLS-1$
int ordinal = 100;
ERepositoryObjectType repositoryType = internalService.createRepositoryType(name, displayName, name, folder, ordinal);
if (curParentNode == null && "JDBC".equals(name)) { //$NON-NLS-1$
Class<ComponentProperties> jdbcClass = ReflectionUtils.getClass(
"org.talend.components.jdbc.wizard.JDBCConnectionWizardProperties",
wizardDefinition.getClass().getClassLoader());
if (jdbcClass != null && wizardDefinition.supportsProperties(jdbcClass)) {
IGenericDBService dbService = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericDBService.class)) {
dbService = (IGenericDBService) GlobalServiceRegister.getDefault().getService(IGenericDBService.class);
}
if (dbService != null) {
dbService.getExtraTypes().add(repositoryType);
}
}
}
}
if (curParentNode != null && !needHide(repositoryType)) {
repNodes.add(internalService.createRepositoryNode(curParentNode, wizardDefinition.getDisplayName(),
repositoryType, ENodeType.SYSTEM_FOLDER));
if (curParentNode != null && !needHide(repositoryType)) {
repNodes.add(internalService.createRepositoryNode(curParentNode, wizardDefinition.getDisplayName(),
repositoryType, ENodeType.SYSTEM_FOLDER));
}
}
}
return repNodes;
@@ -126,10 +130,12 @@ public class GenericWizardService implements IGenericWizardService {
@Override
public List<String> getGenericTypeNames() {
if (typeNames.isEmpty()) {
Set<ComponentWizardDefinition> wizardDefinitions = internalService.getComponentService()
.getTopLevelComponentWizards();
for (ComponentWizardDefinition wizardDefinition : wizardDefinitions) {
typeNames.add(wizardDefinition.getName());
ComponentService componentService = internalService.getComponentService();
if (componentService!=null) {
Set<ComponentWizardDefinition> wizardDefinitions = componentService.getTopLevelComponentWizards();
for (ComponentWizardDefinition wizardDefinition : wizardDefinitions) {
typeNames.add(wizardDefinition.getName());
}
}
}
return typeNames;