Skip to content

Commit

Permalink
TEIIDDES-1326 Resolved some findbugs issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mdrillin committed Aug 21, 2012
1 parent bf3024c commit 3796b81
Show file tree
Hide file tree
Showing 42 changed files with 294 additions and 249 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ protected void inputChanged( Object input,
}
} else {
// OR, create the processor from a resource and an input stream
IProject project = resLeft.getProject();
IProject project = null;
if(resLeft!=null) {
project = resLeft.getProject();
}

if ((project != null) && project.isOpen() && ModelerCore.hasModelNature(project)
&& (resLeft.getType() == IResource.FILE)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ public static List createValidationDescriptor( final IExtension extension ) {
}
if (defaultValue != null) {
ModelerCore.Util.log(IStatus.INFO,
ModelerCore.Util.getString("EclipseConfigurationBuilder.DEBUG.Set_the_DEFAULT_OPTION_to_1") + new Object[] {defaultValue}); //$NON-NLS-1$
ModelerCore.Util.getString("EclipseConfigurationBuilder.DEBUG.Set_the_DEFAULT_OPTION_to_1", new Object[] {defaultValue})); //$NON-NLS-1$
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ MtkXmiHandler.DEBUG.Unable_to_set_the_value_on_EAttribute_since_it_is_unchangeab
ModelVisitorProcessor.Invalid_depth=Invalid depth
ModelResourceIndexBuilder.Error_trying_to_index_resource_1=Error trying to index resource {0}
ModelWorkspaceManager.Error_adding_ChangeNotifier_to_the_model_container_{0}_1=Error adding ChangeNotifier to the model container {0}
EclipseConfigurationBuilder.DEBUG.Set_the_DEFAULT_OPTION_to_1=DEBUG.Set the DEFAULT_OPTION to
EclipseConfigurationBuilder.DEBUG.Set_the_DEFAULT_OPTION_to_1=Set the DEFAULT_OPTION to {0}
EclipseConfigurationBuilder.DEBUG.Created_new_ExtensionDescriptorImpl_instance_1=Created new ExtensionDescriptorImpl instance: id {0}, classname {1}, bundle {2}
ModelerCore.Error_creating_the_DatatypeManager_instance_1=Error creating the DatatypeManager instance
ModelerCore.DEBUG.Created_new_instance_of_a_DatatypeManager_1=Created new instance of a DatatypeManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected IFigure createFigure() {

((DiagramPolylineConnection)connectionFigure).setLineStyle( ((NodeConnectionModel)getModel()).getLineStyle() );
int iStandardWidth = 1;
newDecoration.setLineWidth(iStandardWidth);
if(newDecoration!=null) newDecoration.setLineWidth(iStandardWidth);
((DiagramPolylineConnection)connectionFigure).setLineWidth( iStandardWidth );
((DiagramPolylineConnection)connectionFigure).setForegroundColor(ColorConstants.blue);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static Diagram createPackageDiagram(EObject target, ModelResource modelR
result.setType(PluginConstants.PACKAGE_DIAGRAM_TYPE_ID);
succeeded = true;
} catch (ModelWorkspaceException e) {
if ( modelResource == null || !modelResource.hasErrors() ) {
if ( !modelResource.hasErrors() ) {
// Unexpected ...
String message = DiagramUiConstants.Util.getString("PackageDiagramContentProvider.createPackageDiagramError", modelResource.toString()); //$NON-NLS-1$
DiagramUiConstants.Util.log(IStatus.ERROR, e, message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ private boolean canCreateAssociation() {
final Collection descriptors = ModelerCore.getModelEditor().getNewAssociationDescriptors(selectedEObjects);
if (descriptors.size() == 1) {
final AssociationDescriptor theDescriptor = (AssociationDescriptor)descriptors.iterator().next();
if (theDescriptor != null) printDescriptor(theDescriptor);
if (theDescriptor.isAmbiguous()) DiagramUiConstants.Util.log(IStatus.INFO,
"HiliteDndNodeSelectionEditPolicy.canCreateAssociation() The Association Descriptor is AMBIGUOUS"); //$NON-NLS-1$

if (theDescriptor.isComplete()) canCreate = true;
if(theDescriptor!=null) {
printDescriptor(theDescriptor);
if (theDescriptor.isAmbiguous()) DiagramUiConstants.Util.log(IStatus.INFO,
"HiliteDndNodeSelectionEditPolicy.canCreateAssociation() The Association Descriptor is AMBIGUOUS"); //$NON-NLS-1$
if (theDescriptor.isComplete()) canCreate = true;
}
} else {
// System.out.println(" -->> HDndNSP.canCreateAssociation() # Descriptors = " + descriptors.size());
final Iterator iter = descriptors.iterator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,8 @@ private PreviewVdbStatus getStatus( IPath pvdbPath ) {
this.statusLock.readLock().unlock();
}

if(statuses==null) return null;

for (PreviewVdbStatus status : statuses) {
if (status.getPath().equals(pvdbPath)) return status;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public final class ModelExtensionRegistryView extends ViewPart {

public ModelExtensionRegistryView() {
this.registry = (Platform.isRunning() ? ExtensionPlugin.getInstance().getRegistry() : null);
this.registry.addListener(new RegistryListener() {
if(this.registry!=null) this.registry.addListener(new RegistryListener() {

/**
* {@inheritDoc}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ public int getMaxTablesInSelect() throws SQLException {
*/
@Override
public int getMaxUserNameLength() throws SQLException {
return getMaxUserNameLength();
return getMetadata().getMaxUserNameLength();
}

/* (non-Javadoc)
Expand Down Expand Up @@ -392,31 +392,31 @@ public String getSQLKeywords() throws SQLException {
*/
@Override
public String getStringFunctions() throws SQLException {
return getStringFunctions();
return getMetadata().getStringFunctions();
}

/* (non-Javadoc)
* @See org.teiid.designer.jdbc.metadata.Capabilities#getSystemFunctions()
*/
@Override
public String getSystemFunctions() throws SQLException {
return getSystemFunctions();
return getMetadata().getSystemFunctions();
}

/* (non-Javadoc)
* @See org.teiid.designer.jdbc.metadata.Capabilities#getTimeDateFunctions()
*/
@Override
public String getTimeDateFunctions() throws SQLException {
return getTimeDateFunctions();
return getMetadata().getTimeDateFunctions();
}

/* (non-Javadoc)
* @See org.teiid.designer.jdbc.metadata.Capabilities#getTypeInfo()
*/
@Override
public ResultSet getTypeInfo() throws SQLException {
return getTypeInfo();
return getMetadata().getTypeInfo();
}

/* (non-Javadoc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,109 +131,110 @@ public List<SchemaNode> getSchemaForSelectedOperation(final int type,
}

List<Object> elementArrayList = new ArrayList<Object>();

for (Part part : partArray) {
partElementName = getPartElementName(part);
String namespace = part.getElementNamespace();

if (type == ProcedureInfo.REQUEST) {
this.requestSchemaTreeModel.setDefaultNamespace(namespace);
}else{
this.responseSchemaTreeModel.setDefaultNamespace(namespace);
}

boolean foundElement = false;

for (XSDSchema schema : schemas) {

EList<XSDElementDeclaration> elements = schema
.getElementDeclarations();
for (XSDElementDeclaration element : elements) {
String elementName = element.getName();
if (elementName.equals(partElementName)) {
if (element.getTypeDefinition() instanceof XSDSimpleTypeDefinition) {
elementDeclaration = element;
} else {
elementDeclaration = element
.getTypeDefinition();
}

foundElement = true;
try {
if (type == ProcedureInfo.REQUEST) {
this.requestSchemaTreeModel = describe(schema,
elementName,
element,
requestSchemaTreeModel);
}
else {
this.responseSchemaTreeModel = describe(schema,
elementName,
element,
responseSchemaTreeModel);
}
}
catch (ModelerCoreException ex) {
openErrorDialog(ex.getMessage());
}
catch (StackOverflowError e) {
/*
* Can occur if the depth threshold is set too high.
* Current value should be fine for most systems but
* just in case...
*
* Eclipse will show a nasty dialog and offer to
* close the workbench which is confusing better to
* exit a little more gracefully.
*/
String message = NLS
.bind(Messages.Error_GeneratingSchemaModelCircularReferenceStackOverflow,
MAX_DEPTH,
WSDL_SCHEMA_HANDLER_RECURSIVE_DEPTH_PROPERTY);
openErrorDialog(message);
System.exit(1);
}

elementArrayList.add(elementDeclaration);
break;
}
}


if (foundElement == true)
break;

if (elementDeclaration == null) {

EList<XSDTypeDefinition> types = schema.getTypeDefinitions();
for (XSDTypeDefinition xsdType : types) {
String elementName = xsdType.getName();
if (elementName.equals(partElementName)) {
elementDeclaration = xsdType;
foundElement = true;
try {
if (type == ProcedureInfo.REQUEST){
this.requestSchemaTreeModel = describe(schema, elementName, null, requestSchemaTreeModel);
}else{
this.responseSchemaTreeModel = describe(schema, elementName, null, responseSchemaTreeModel);
}
} catch (ModelerCoreException ex) {
ErrorDialog.openError(this.operationsDetailsPage.getShell(), Messages.Error_GeneratingSchemaModelDueToCircularReferences_title, null, new Status(IStatus.WARNING, ModelGeneratorWsdlUiConstants.PLUGIN_ID, Messages.Error_GeneratingSchemaModelDueToCircularReferences));
}
elementArrayList.add(elementDeclaration);
break;
}
}
}

// We already found our element. No need to look through anymore
// schemas
if (foundElement) {
foundElement = false;
break;
}
}

if(partArray!=null) {
for (Part part : partArray) {
partElementName = getPartElementName(part);
String namespace = part.getElementNamespace();

if (type == ProcedureInfo.REQUEST) {
this.requestSchemaTreeModel.setDefaultNamespace(namespace);
}else{
this.responseSchemaTreeModel.setDefaultNamespace(namespace);
}

boolean foundElement = false;

for (XSDSchema schema : schemas) {

EList<XSDElementDeclaration> elements = schema
.getElementDeclarations();
for (XSDElementDeclaration element : elements) {
String elementName = element.getName();
if (elementName.equals(partElementName)) {
if (element.getTypeDefinition() instanceof XSDSimpleTypeDefinition) {
elementDeclaration = element;
} else {
elementDeclaration = element
.getTypeDefinition();
}

foundElement = true;
try {
if (type == ProcedureInfo.REQUEST) {
this.requestSchemaTreeModel = describe(schema,
elementName,
element,
requestSchemaTreeModel);
}
else {
this.responseSchemaTreeModel = describe(schema,
elementName,
element,
responseSchemaTreeModel);
}
}
catch (ModelerCoreException ex) {
openErrorDialog(ex.getMessage());
}
catch (StackOverflowError e) {
/*
* Can occur if the depth threshold is set too high.
* Current value should be fine for most systems but
* just in case...
*
* Eclipse will show a nasty dialog and offer to
* close the workbench which is confusing better to
* exit a little more gracefully.
*/
String message = NLS
.bind(Messages.Error_GeneratingSchemaModelCircularReferenceStackOverflow,
MAX_DEPTH,
WSDL_SCHEMA_HANDLER_RECURSIVE_DEPTH_PROPERTY);
openErrorDialog(message);
System.exit(1);
}

elementArrayList.add(elementDeclaration);
break;
}
}


if (foundElement == true)
break;

if (elementDeclaration == null) {

EList<XSDTypeDefinition> types = schema.getTypeDefinitions();
for (XSDTypeDefinition xsdType : types) {
String elementName = xsdType.getName();
if (elementName.equals(partElementName)) {
elementDeclaration = xsdType;
foundElement = true;
try {
if (type == ProcedureInfo.REQUEST){
this.requestSchemaTreeModel = describe(schema, elementName, null, requestSchemaTreeModel);
}else{
this.responseSchemaTreeModel = describe(schema, elementName, null, responseSchemaTreeModel);
}
} catch (ModelerCoreException ex) {
ErrorDialog.openError(this.operationsDetailsPage.getShell(), Messages.Error_GeneratingSchemaModelDueToCircularReferences_title, null, new Status(IStatus.WARNING, ModelGeneratorWsdlUiConstants.PLUGIN_ID, Messages.Error_GeneratingSchemaModelDueToCircularReferences));
}
elementArrayList.add(elementDeclaration);
break;
}
}
}

// We already found our element. No need to look through anymore
// schemas
if (foundElement) {
foundElement = false;
break;
}
}

}
}

Collection<SchemaNode> nodeList = new ArrayList<SchemaNode>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,20 +445,20 @@ public String getWrapperProcedureSqlString(Properties properties) {
*/

// Request procedure name may have been overridden
String requestProcedureName = properties.getProperty(ProcedureGenerator.KEY_REQUEST_PROCEDURE_NAME);
if( requestProcedureName == null ) {
requestProcedureName = this.getRequestProcedureName();
}
// Request procedure name may have been overridden
String responseProcedureName = properties.getProperty(ProcedureGenerator.KEY_RESPONSE_PROCEDURE_NAME);
if( responseProcedureName == null ) {
responseProcedureName = this.getResponseProcedureName();
}
// Request procedure name may have been overridden
String wrapperProcedureName = properties.getProperty(ProcedureGenerator.KEY_WRAPPER_PROCEDURE_NAME);
if( wrapperProcedureName == null ) {
wrapperProcedureName = this.getRequestProcedureName();
}
// String requestProcedureName = properties.getProperty(ProcedureGenerator.KEY_REQUEST_PROCEDURE_NAME);
// if( requestProcedureName == null ) {
// requestProcedureName = this.getRequestProcedureName();
// }
// // Request procedure name may have been overridden
// String responseProcedureName = properties.getProperty(ProcedureGenerator.KEY_RESPONSE_PROCEDURE_NAME);
// if( responseProcedureName == null ) {
// responseProcedureName = this.getResponseProcedureName();
// }
// // Request procedure name may have been overridden
// String wrapperProcedureName = properties.getProperty(ProcedureGenerator.KEY_WRAPPER_PROCEDURE_NAME);
// if( wrapperProcedureName == null ) {
// wrapperProcedureName = this.getRequestProcedureName();
// }

StringBuilder sb = new StringBuilder();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public Collection createTables( Operation[] opers ) throws ModelBuildingExceptio

if ((root == null && elementNamespace.trim().length() == 0)
|| (root != null && root.getNamespace().equalsIgnoreCase(elementNamespace))) {
if (root.getName().equalsIgnoreCase(elementName)) {
if (root!=null && root.getName().equalsIgnoreCase(elementName)) {
theElement = root;
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public SchemaRepresentation (Object syncObject)
m_customCatalogName = null;
m_namespaces = new HashMap();
m_defaultNamespaces = new ArrayList();
elements = new ArrayList();
}

//////////////////////////////////////////////
Expand Down

0 comments on commit 3796b81

Please sign in to comment.