Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 165544 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/OperationImportWizardPage.java (-15 / +40 lines)
Lines 21-27 Link Here
21
import javax.wsdl.Operation;
21
import javax.wsdl.Operation;
22
import javax.wsdl.PortType;
22
import javax.wsdl.PortType;
23
23
24
import org.eclipse.emf.common.util.URI;
25
import org.eclipse.jface.dialogs.Dialog;
24
import org.eclipse.jface.dialogs.Dialog;
26
import org.eclipse.jface.viewers.CheckStateChangedEvent;
25
import org.eclipse.jface.viewers.CheckStateChangedEvent;
27
import org.eclipse.jface.viewers.CheckboxTreeViewer;
26
import org.eclipse.jface.viewers.CheckboxTreeViewer;
Lines 49-56 Link Here
49
	private Definition _wsdlDefinition;
48
	private Definition _wsdlDefinition;
50
	private PortType[] _existingPortTypes = new PortType[0];
49
	private PortType[] _existingPortTypes = new PortType[0];
51
	private Operation[] _importedOperations;
50
	private Operation[] _importedOperations;
52
	private URI _importedWsdlURI;
51
	
53
54
	public OperationImportWizardPage()
52
	public OperationImportWizardPage()
55
	{
53
	{
56
		super("ImportOperationWizardPage");
54
		super("ImportOperationWizardPage");
Lines 137-143 Link Here
137
		// _viewer.expandToLevel(2);
135
		// _viewer.expandToLevel(2);
138
		// Checked the Port types provided by constructor
136
		// Checked the Port types provided by constructor
139
		doIntialCheckedElements();
137
		doIntialCheckedElements();
140
		_viewer.setGrayedElements(_existingPortTypes);
138
		//_viewer.setGrayedElements(_existingPortTypes);
141
		updateStatus(null);
139
		updateStatus(null);
142
	}
140
	}
143
141
Lines 147-162 Link Here
147
		initialize();
145
		initialize();
148
	}
146
	}
149
	
147
	
150
	public void setImportedWsdlURI(URI importedWsdlURI)
151
	{
152
		_importedWsdlURI = importedWsdlURI;
153
	}
154
	
155
	public URI getImportedWsdlURI()
156
	{
157
		return _importedWsdlURI;
158
	}
159
160
	private List getConsolidatedPortList(PortType[] ports)
148
	private List getConsolidatedPortList(PortType[] ports)
161
	{
149
	{
162
		List portTypes = new LinkedList();
150
		List portTypes = new LinkedList();
Lines 172-178 Link Here
172
	protected void doIntialCheckedElements()
160
	protected void doIntialCheckedElements()
173
	{
161
	{
174
		for (int i = 0; i < _existingPortTypes.length; i++)
162
		for (int i = 0; i < _existingPortTypes.length; i++)
163
		{
175
			_viewer.setSubtreeChecked(_existingPortTypes[i], true);
164
			_viewer.setSubtreeChecked(_existingPortTypes[i], true);
165
		}
166
			
176
	}
167
	}
177
168
178
	private void handleCheckStateChanged(CheckStateChangedEvent event)
169
	private void handleCheckStateChanged(CheckStateChangedEvent event)
Lines 195-202 Link Here
195
				return;
186
				return;
196
			}
187
			}
197
		}
188
		}
198
189
		_viewer.setGrayChecked(event.getElement(), false);
199
		_viewer.setSubtreeChecked(event.getElement(), event.getChecked());
190
		_viewer.setSubtreeChecked(event.getElement(), event.getChecked());
191
		changeParentCheckStatus(event.getElement());
200
		Operation[] checkedOperations = getCheckedOperations();
192
		Operation[] checkedOperations = getCheckedOperations();
201
		OperationImportValidator validator = new OperationImportValidator(
193
		OperationImportValidator validator = new OperationImportValidator(
202
				checkedOperations);
194
				checkedOperations);
Lines 212-217 Link Here
212
		}
204
		}
213
		_importedOperations = getSelectedOperation();
205
		_importedOperations = getSelectedOperation();
214
	}
206
	}
207
	
208
	private void changeParentCheckStatus(Object checkedElement)
209
	{
210
		Object parent = _contentProvider.getParent(checkedElement);
211
		if(parent == null)
212
			return;
213
		Object[] childrens = _contentProvider.getChildren(parent);
214
		int checkedChildrensSize = 0;
215
		for(int i=0;i<childrens.length;i++)
216
		{	
217
			if(_viewer.getChecked(childrens[i]))
218
				checkedChildrensSize++;
219
		}
220
		// If all childrens checked, make the parent checked
221
		if(checkedChildrensSize == childrens.length)
222
		{
223
			_viewer.setGrayChecked(parent, false);
224
			_viewer.setChecked(parent, true);
225
			return;
226
		}
227
		// If not all but any one of the childrens checked, make the parent grayed
228
		if(checkedChildrensSize>0)
229
		{
230
			_viewer.setGrayChecked(parent, true);
231
			return;
232
		}
233
		// If none of them is checked, then make the parent unchecked
234
		if(checkedChildrensSize == 0)
235
		{
236
			_viewer.setGrayChecked(parent, false);
237
			return;
238
		}
239
	}
215
240
216
	private void updateStatus(String message)
241
	private void updateStatus(String message)
217
	{
242
	{
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/OperationImportWizard.java (-4 / +5 lines)
Lines 29-34 Link Here
29
import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain;
29
import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain;
30
import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition;
30
import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition;
31
import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages;
31
import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages;
32
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog;
32
import org.eclipse.ui.INewWizard;
33
import org.eclipse.ui.INewWizard;
33
import org.eclipse.ui.IWorkbench;
34
import org.eclipse.ui.IWorkbench;
34
35
Lines 44-49 Link Here
44
	private Definition _wsdlDefinition;
45
	private Definition _wsdlDefinition;
45
	private PortType[] _existingPortTypes = new PortType[0];
46
	private PortType[] _existingPortTypes = new PortType[0];
46
	private OperationImportWizardPage _importPage;
47
	private OperationImportWizardPage _importPage;
48
	private URI _importedWsdlURI;
47
	
49
	
48
	public OperationImportWizard(CapabilityDomain capabilityDomain,
50
	public OperationImportWizard(CapabilityDomain capabilityDomain,
49
			Definition definition)
51
			Definition definition)
Lines 83-89 Link Here
83
		}
85
		}
84
		catch (Exception e)
86
		catch (Exception e)
85
		{
87
		{
86
			e.printStackTrace();
88
			WsdmToolingLog.logError(e.getMessage(), e);
87
		}
89
		}
88
		return false;
90
		return false;
89
	}
91
	}
Lines 93-101 Link Here
93
		Operation[] importOperations = _importPage.getImportedOperations();
95
		Operation[] importOperations = _importPage.getImportedOperations();
94
		CapabilityDefinition capabilityDefinition = (CapabilityDefinition) _capabilityDomain
96
		CapabilityDefinition capabilityDefinition = (CapabilityDefinition) _capabilityDomain
95
				.getCapability().getWsdlDefinition();
97
				.getCapability().getWsdlDefinition();
96
		URI importedWsdlURI = _importPage.getImportedWsdlURI();
97
		ImportOperationCommand command = new ImportOperationCommand(
98
		ImportOperationCommand command = new ImportOperationCommand(
98
				capabilityDefinition, importOperations, importedWsdlURI, monitor);
99
				capabilityDefinition, _wsdlDefinition, importOperations, _importedWsdlURI, monitor);
99
		command.execute();
100
		command.execute();
100
		Operation[] newOperations = command.getNewOperations();
101
		Operation[] newOperations = command.getNewOperations();
101
		_capabilityDomain.getCapability().getOperations().addAll(
102
		_capabilityDomain.getCapability().getOperations().addAll(
Lines 108-113 Link Here
108
	
109
	
109
	public void setImportedWsdlURI(URI importedWsdlURI)
110
	public void setImportedWsdlURI(URI importedWsdlURI)
110
	{
111
	{
111
		_importPage.setImportedWsdlURI(importedWsdlURI);
112
		_importedWsdlURI = importedWsdlURI;
112
	}
113
	}
113
}
114
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/wsdl/XSDSchemaMerger.java (-7 / +17 lines)
Lines 32-42 Link Here
32
32
33
	private XSDSchema _schema;
33
	private XSDSchema _schema;
34
	private List _allResultedSchema;
34
	private List _allResultedSchema;
35
	private List _allAddedSchemaURIs;
35
36
36
	public XSDSchemaMerger(XSDSchema schema)
37
	public XSDSchemaMerger(XSDSchema schema)
37
	{
38
	{
38
		_schema = schema;
39
		_schema = schema;
39
		_allResultedSchema = new LinkedList();
40
		_allResultedSchema = new LinkedList();
41
		_allAddedSchemaURIs = new LinkedList();
40
		addSchema(_schema);
42
		addSchema(_schema);
41
	}
43
	}
42
44
Lines 74-88 Link Here
74
76
75
	private void addSchema(XSDSchema givenSchema)
77
	private void addSchema(XSDSchema givenSchema)
76
	{
78
	{
77
		XSDSchema schema = getSchema(givenSchema.getTargetNamespace());
79
		if(isAlreadyAdded(givenSchema))
80
			return;
81
		XSDSchema clonedSchema = (XSDSchema) givenSchema.cloneConcreteComponent(true, true);
82
		clonedSchema.setSchemaLocation(givenSchema.getSchemaLocation());
83
		XSDSchema schema = getSchema(clonedSchema.getTargetNamespace());
78
		if (schema != null)
84
		if (schema != null)
79
		{
85
			schema.getContents().addAll(clonedSchema.getContents());
80
			List givenSchemaContents = givenSchema.getContents();
81
			for (int i = 0; i < givenSchemaContents.size(); i++)
82
				schema.getContents().add(givenSchemaContents.get(i));
83
		}
84
		else
86
		else
85
			_allResultedSchema.add(givenSchema);
87
			_allResultedSchema.add(clonedSchema);
88
		String schemaLocation = clonedSchema.getSchemaLocation();
89
		_allAddedSchemaURIs.add(schemaLocation);
90
	}
91
	
92
	private boolean isAlreadyAdded(XSDSchema givenSchema)
93
	{
94
		String schemaLocation = givenSchema.getSchemaLocation();
95
		return _allAddedSchemaURIs.contains(schemaLocation);
86
	}
96
	}
87
97
88
	private XSDSchema getSchema(String targetNamespace)
98
	private XSDSchema getSchema(String targetNamespace)
(-)src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewWSDLMessageNameGenerator.java (-5 / +6 lines)
Lines 23-36 Link Here
23
public class NewWSDLMessageNameGenerator implements INewNameGenerator
23
public class NewWSDLMessageNameGenerator implements INewNameGenerator
24
{
24
{
25
	private Definition _definition;
25
	private Definition _definition;
26
	private String _namePattern;
26
	private String _pattern;
27
27
28
	public NewWSDLMessageNameGenerator(Definition definition, String namePattern)
28
	public NewWSDLMessageNameGenerator(Definition definition, String namePattern)
29
	{
29
	{
30
		_definition = definition;
30
		_definition = definition;
31
		if (namePattern == null || namePattern.trim().equals(""))
31
		if (namePattern == null || namePattern.trim().equals(""))
32
			namePattern = "NewMessage";
32
			namePattern = "NewMessage";
33
		_namePattern = namePattern;
33
		_pattern = namePattern;
34
	}
34
	}
35
35
36
	public NewWSDLMessageNameGenerator(Definition definition)
36
	public NewWSDLMessageNameGenerator(Definition definition)
Lines 41-52 Link Here
41
	public String getNewName()
41
	public String getNewName()
42
	{
42
	{
43
		int count = 0;
43
		int count = 0;
44
		while (WsdlUtils.getWSDLMessage(_definition, _namePattern) != null)
44
		String namePattern = _pattern+count;
45
		while (WsdlUtils.getWSDLMessage(_definition, namePattern) != null)
45
		{
46
		{
46
			_namePattern = _namePattern + count;
47
			count++;
47
			count++;
48
			namePattern = _pattern+count;
48
		}
49
		}
49
		return _namePattern;
50
		return namePattern;
50
	}
51
	}
51
52
52
}
53
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewXSDElementNameGenerator.java (-5 / +6 lines)
Lines 22-35 Link Here
22
public class NewXSDElementNameGenerator implements INewNameGenerator
22
public class NewXSDElementNameGenerator implements INewNameGenerator
23
{
23
{
24
	private XSDSchema _schema;
24
	private XSDSchema _schema;
25
	private String _namePattern;
25
	private String _pattern;
26
26
27
	public NewXSDElementNameGenerator(XSDSchema schema, String namePattern)
27
	public NewXSDElementNameGenerator(XSDSchema schema, String namePattern)
28
	{
28
	{
29
		_schema = schema;
29
		_schema = schema;
30
		if (namePattern == null || namePattern.trim().equals(""))
30
		if (namePattern == null || namePattern.trim().equals(""))
31
			namePattern = "NewElement";
31
			namePattern = "NewElement";
32
		_namePattern = namePattern;
32
		_pattern = namePattern;
33
	}
33
	}
34
34
35
	public NewXSDElementNameGenerator(XSDSchema schema)
35
	public NewXSDElementNameGenerator(XSDSchema schema)
Lines 40-51 Link Here
40
	public String getNewName()
40
	public String getNewName()
41
	{
41
	{
42
		int count = 0;
42
		int count = 0;
43
		while (XsdUtils.getXSDElementDeclarationOfName(_schema, _namePattern) != null)
43
		String namePattern = _pattern+count;
44
		while (XsdUtils.getXSDElementDeclarationOfName(_schema, namePattern) != null)
44
		{
45
		{
45
			_namePattern = _namePattern + count;
46
			count++;
46
			count++;
47
			namePattern = _pattern+count;
47
		}
48
		}
48
		return _namePattern;
49
		return namePattern;
49
	}
50
	}
50
51
51
}
52
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/ui/internal/namegenerator/NewIFileNameGenerator.java (-8 / +11 lines)
Lines 26-40 Link Here
26
{
26
{
27
	private IResource _resource;
27
	private IResource _resource;
28
	private String _namePattern;
28
	private String _namePattern;
29
	private String _fileName;
30
	private String _fileExtension;
29
31
30
	public NewIFileNameGenerator(IResource resource, String namePattern)
32
	public NewIFileNameGenerator(IResource resource, String namePattern)
31
	{
33
	{
32
		_resource = resource;
34
		_resource = resource;
33
		if (namePattern == null || namePattern.trim().equals(""))
35
		if (namePattern == null || namePattern.trim().equals("") || namePattern.indexOf('.') == -1)
34
			namePattern = "NewFile.tmp";
35
		if (namePattern.indexOf('.') == -1)
36
		{
36
		{
37
			namePattern = "NewFile.tmp";
37
			namePattern = "NewFile.tmp";
38
			_fileName = "NewFile";
39
			_fileExtension = "tmp";
40
		}			
41
		else
42
		{
43
			_fileName = namePattern.substring(0,namePattern.lastIndexOf('.'));
44
			_fileExtension = namePattern.substring(namePattern.lastIndexOf('.')+1);
38
		}
45
		}
39
		_namePattern = namePattern;
46
		_namePattern = namePattern;
40
	}
47
	}
Lines 70-80 Link Here
70
		int count = 0;
77
		int count = 0;
71
		while (isFileExists(members, _namePattern))
78
		while (isFileExists(members, _namePattern))
72
		{
79
		{
73
			String fileNameWithoutExtn = _namePattern.substring(0, _namePattern
80
			_namePattern = _fileName + count + "." + _fileExtension;
74
					.lastIndexOf('.'));
75
			String fileExtn = _namePattern.substring(_namePattern
76
					.lastIndexOf('.') + 1);
77
			_namePattern = fileNameWithoutExtn + count + "." + fileExtn;
78
			count++;
81
			count++;
79
		}
82
		}
80
		return _namePattern;
83
		return _namePattern;
(-)src/org/eclipse/tptp/wsdm/tooling/wizard/capability/internal/NewCapabilityWizard.java (-100 / +21 lines)
Lines 19-24 Link Here
19
import java.util.HashMap;
19
import java.util.HashMap;
20
import java.util.Map;
20
import java.util.Map;
21
21
22
import javax.wsdl.Definition;
22
import javax.wsdl.Operation;
23
import javax.wsdl.Operation;
23
import javax.wsdl.PortType;
24
import javax.wsdl.PortType;
24
import javax.wsdl.Types;
25
import javax.wsdl.Types;
Lines 94-103 Link Here
94
95
95
	private IFile _capFile;
96
	private IFile _capFile;
96
97
97
	private boolean canContinue = true;
98
99
	private boolean isOverwriteXSD = true;
100
101
	private final static String DEFAULT_DESCRIPTION = "Example capability";
98
	private final static String DEFAULT_DESCRIPTION = "Example capability";
102
99
103
	/**
100
	/**
Lines 195-223 Link Here
195
		_options.put(CapabilityWizardKeys.IMPORT_OPERATION_KEY,
192
		_options.put(CapabilityWizardKeys.IMPORT_OPERATION_KEY,
196
				importedOperations);
193
				importedOperations);
197
194
198
		IRunnableWithProgress shouldOverwriteOperation = new IRunnableWithProgress()
199
		{
200
			public void run(IProgressMonitor monitor)
201
					throws InvocationTargetException, InterruptedException
202
			{
203
				shouldOverWriteXSD();
204
			}
205
		};
206
		try
207
		{
208
			getContainer().run(false, false, shouldOverwriteOperation);
209
		}
210
		catch (InvocationTargetException e1)
211
		{
212
			WsdmToolingLog
213
					.logError(Messages.FAILED_CREATE_CAP_ERROR_ + " ", e1);
214
		}
215
		catch (InterruptedException e1)
216
		{
217
			WsdmToolingLog
218
					.logError(Messages.FAILED_CREATE_CAP_ERROR_ + " ", e1);
219
		}
220
221
		IRunnableWithProgress op = new IRunnableWithProgress()
195
		IRunnableWithProgress op = new IRunnableWithProgress()
222
		{
196
		{
223
			public void run(IProgressMonitor monitor)
197
			public void run(IProgressMonitor monitor)
Lines 248-273 Link Here
248
			}
222
			}
249
		};
223
		};
250
224
251
		if (canContinue)
225
		try
252
		{
226
		{
253
			try
227
			getContainer().run(true, false, op);
254
			{
255
				getContainer().run(true, false, op);
256
			}
257
			catch (InterruptedException e)
258
			{
259
				WsdmToolingLog.logError(
260
						Messages.FAILED_CREATE_CAP_ERROR_ + " ", e);
261
				return false;
262
			}
263
			catch (InvocationTargetException e)
264
			{
265
				Throwable realException = e.getTargetException();
266
				MessageDialog.openError(getShell(), "Error", realException
267
						.getMessage());
268
				return false;
269
			}
270
		}
228
		}
229
		catch (InterruptedException e)
230
		{
231
			WsdmToolingLog.logError(
232
					Messages.FAILED_CREATE_CAP_ERROR_ + " ", e);
233
			return false;
234
		}
235
		catch (InvocationTargetException e)
236
		{
237
			Throwable realException = e.getTargetException();
238
			MessageDialog.openError(getShell(), "Error", realException
239
					.getMessage());
240
			return false;
241
		}		
271
		return true;
242
		return true;
272
	}
243
	}
273
244
Lines 275-282 Link Here
275
			IOException, InvocationTargetException, InterruptedException
246
			IOException, InvocationTargetException, InterruptedException
276
	{
247
	{
277
		verifyContainer();
248
		verifyContainer();
278
		if (isOverwriteXSD)
249
		doFinishXSD(monitor);
279
			doFinishXSD(monitor);
280
		doFinishRMD(monitor);
250
		doFinishRMD(monitor);
281
		doFinishCapFile(monitor);
251
		doFinishCapFile(monitor);
282
		refreshContainer(monitor);
252
		refreshContainer(monitor);
Lines 288-342 Link Here
288
		// TODO Put the code to verify container
258
		// TODO Put the code to verify container
289
	}
259
	}
290
260
291
	private void shouldOverWriteXSD()
292
	{
293
		// TODO
294
		// XSDSchema[] importedXsd = (XSDSchema[]) _options
295
		// .get(CapabilityWizardKeys.IMPORT_XSD_KEY);
296
		// String xsdFilePath = (String) _options
297
		// .get(CapabilityWizardKeys.XSD_FILE_PATH_KEY);
298
		// if (importedXsd.length != 0)
299
		// {
300
		// for (int i = 0; i < importedXsd.length; i++)
301
		// {
302
		// IFile importedXsdFile = null;
303
		// try
304
		// {
305
		// importedXsdFile = EclipseUtils.getIFile(importedXsd[i]
306
		// .eResource().getURI().toString());
307
		// } catch (CoreException e)
308
		// {
309
		// WsdmToolingLog.logError(e.getLocalizedMessage(), e);
310
		// }
311
		// if (importedXsdFile.exists()
312
		// && importedXsdFile.getFullPath().toString().equals(
313
		// xsdFilePath))
314
		// {
315
		// isOverwriteXSD = false;
316
		// canContinue = true;
317
		// return;
318
		// }
319
		// }
320
		// }
321
		//
322
		// IFile xsdFile = null;
323
		// try
324
		// {
325
		// xsdFile = EclipseUtils.getIFile(xsdFilePath);
326
		// } catch (CoreException e)
327
		// {
328
		// WsdmToolingLog.logError(e.getLocalizedMessage(), e);
329
		// }
330
		// if (xsdFile.exists())
331
		// {
332
		// isOverwriteXSD = MessageDialog
333
		// .openConfirm(getShell(), Messages.CONFIRM_MESSAGE, Messages
334
		// .bind(Messages.OVERWRITE_FILE_MESSAGE, xsdFile
335
		// .getName()));
336
		// canContinue = isOverwriteXSD;
337
		// }
338
	}
339
340
	private void refreshContainer(IProgressMonitor monitor)
261
	private void refreshContainer(IProgressMonitor monitor)
341
			throws CoreException
262
			throws CoreException
342
	{
263
	{
Lines 493-500 Link Here
493
		String capNS = (String) _options.get(CapabilityWizardKeys.CAP_NS_KEY);
414
		String capNS = (String) _options.get(CapabilityWizardKeys.CAP_NS_KEY);
494
		XSDSchema schema = _wsdlCapDefinition.createOrFindSchema(capNS);
415
		XSDSchema schema = _wsdlCapDefinition.createOrFindSchema(capNS);
495
		createAnnotation(schema);
416
		createAnnotation(schema);
496
		if (isOverwriteXSD)
417
		createPropXSDInclude(schema);
497
			createPropXSDInclude(schema);
498
		createResourceProperties(schema);
418
		createResourceProperties(schema);
499
	}
419
	}
500
420
Lines 551-559 Link Here
551
				.get(CapabilityWizardKeys.IMPORT_OPERATION_KEY);
471
				.get(CapabilityWizardKeys.IMPORT_OPERATION_KEY);
552
		if(importOperations.length!=0)
472
		if(importOperations.length!=0)
553
		{
473
		{
554
			URI importedWsdlURI = _importOperationPage.getImportedWsdlURI();
474
			URI importedWsdlURI = _importerPage.getImportedWsdlURI();
475
			Definition importedWsdlDefinition = _importerPage.getImportedWsdlDefinition();
555
			ImportOperationCommand command = new ImportOperationCommand(
476
			ImportOperationCommand command = new ImportOperationCommand(
556
					_wsdlCapDefinition, importOperations, importedWsdlURI);
477
					_wsdlCapDefinition, importedWsdlDefinition, importOperations, importedWsdlURI);
557
			command.execute();
478
			command.execute();
558
		}		
479
		}		
559
	}
480
	}
(-)src/org/eclipse/tptp/wsdm/tooling/wizard/capability/internal/CapabilityModelImporterPage.java (-36 / +39 lines)
Lines 13-23 Link Here
13
package org.eclipse.tptp.wsdm.tooling.wizard.capability.internal;
13
package org.eclipse.tptp.wsdm.tooling.wizard.capability.internal;
14
14
15
import javax.wsdl.Definition;
15
import javax.wsdl.Definition;
16
import javax.wsdl.Operation;
16
import javax.wsdl.WSDLException;
17
import javax.wsdl.factory.WSDLFactory;
18
import javax.wsdl.xml.WSDLReader;
17
19
18
import org.eclipse.core.resources.IFile;
20
import org.eclipse.core.resources.IFile;
19
import org.eclipse.core.resources.IWorkspaceRoot;
21
import org.eclipse.core.resources.IWorkspaceRoot;
20
import org.eclipse.core.resources.ResourcesPlugin;
22
import org.eclipse.core.resources.ResourcesPlugin;
23
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.Path;
24
import org.eclipse.core.runtime.Path;
22
import org.eclipse.emf.common.util.URI;
25
import org.eclipse.emf.common.util.URI;
23
import org.eclipse.jface.dialogs.Dialog;
26
import org.eclipse.jface.dialogs.Dialog;
Lines 40-51 Link Here
40
import org.eclipse.tptp.wsdm.tooling.dialog.provisional.XSDBrowseDialog;
43
import org.eclipse.tptp.wsdm.tooling.dialog.provisional.XSDBrowseDialog;
41
import org.eclipse.tptp.wsdm.tooling.editor.capability.imports.wsdl.OperationImportWizardPage;
44
import org.eclipse.tptp.wsdm.tooling.editor.capability.imports.wsdl.OperationImportWizardPage;
42
import org.eclipse.tptp.wsdm.tooling.editor.capability.imports.xsd.PropertyImportWizardPage;
45
import org.eclipse.tptp.wsdm.tooling.editor.capability.imports.xsd.PropertyImportWizardPage;
43
import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition;
44
import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages;
46
import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.internal.Messages;
45
import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils;
47
import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils;
46
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils;
48
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog;
47
import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils;
49
import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils;
48
import org.eclipse.xsd.XSDSchema;
50
import org.eclipse.xsd.XSDSchema;
51
import org.xml.sax.InputSource;
49
52
50
/**
53
/**
51
 * Wizard page to import capability from XSD and WSDL files.
54
 * Wizard page to import capability from XSD and WSDL files.
Lines 71-81 Link Here
71
74
72
	private Button _browseWSDL;
75
	private Button _browseWSDL;
73
76
74
	private Object[] _checkedItems;
75
76
	private Operation[] _importedOperations = new Operation[0];
77
78
	private boolean _canFlipToNextPage = false;
77
	private boolean _canFlipToNextPage = false;
78
	
79
	private URI _importedWsdlURI = null;
80
	
81
	private Definition _importedWsdlDefinition = null;
79
82
80
	/**
83
	/**
81
	 * Creates new object of this class.
84
	 * Creates new object of this class.
Lines 275-283 Link Here
275
		if (dialog.open() == Window.OK)
278
		if (dialog.open() == Window.OK)
276
		{
279
		{
277
			IFile browsedFile = (IFile) dialog.getFirstResult();
280
			IFile browsedFile = (IFile) dialog.getFirstResult();
278
			XSDSchema xsdSchema = XsdUtils.getSchema(browsedFile);
279
			_xsdFilePathText.setText(browsedFile.getFullPath().toString());
280
			// TODO Check for valid file
281
			// TODO Check for valid file
282
			XsdUtils.getSchema(browsedFile);
283
			_xsdFilePathText.setText(browsedFile.getFullPath().toString());			
281
		}
284
		}
282
	}
285
	}
283
286
Lines 289-298 Link Here
289
			IFile browsedFile = (IFile) dialog.getFirstResult();
292
			IFile browsedFile = (IFile) dialog.getFirstResult();
290
			try
293
			try
291
			{
294
			{
292
				WsdlUtils.getCapabilityDefinition(browsedFile);
295
				getWsdlDefinition(browsedFile);
293
			}
296
			}
294
			catch (Exception e)
297
			catch (Exception e)
295
			{
298
			{
299
				WsdmToolingLog.logError(e.getMessage(), e);
296
				MessageDialog
300
				MessageDialog
297
						.openError(
301
						.openError(
298
								getShell(),
302
								getShell(),
Lines 303-326 Link Here
303
			_wsdlFilePathText.setText(browsedFile.getFullPath().toString());
307
			_wsdlFilePathText.setText(browsedFile.getFullPath().toString());
304
		}
308
		}
305
	}
309
	}
306
310
	
307
	/**
311
	private Definition getWsdlDefinition(IFile file) throws WSDLException, CoreException
308
	 * Returns the imported XSD schemas specified.
312
	{
309
	 */
313
		WSDLFactory factory = WSDLFactory.newInstance();
310
	/*
314
		WSDLReader reader = factory.newWSDLReader();
311
	 * protected XSDSchema[] getSchemaToImport() {
315
		InputSource inputSource = new InputSource(file.getContents());
312
	 * if(_emptyCapability.getSelection() || _fromWSDL.getSelection()) return
316
		String fileLocation = file.getLocation().toString();
313
	 * new XSDSchema[0]; return new XSDSchema[0]; }
317
		Definition definition = reader.readWSDL(fileLocation, inputSource);
314
	 */
318
		return definition;
315
319
	}
316
	/**
317
	 * Returns the imported Operations specified.
318
	 */
319
	/*
320
	 * protected Operation[] getOperationsToImport() {
321
	 * if(_emptyCapability.getSelection() || _fromXSD.getSelection()) return new
322
	 * Operation[0]; return _importedOperations; }
323
	 */
324
320
325
	private void dialogChanged()
321
	private void dialogChanged()
326
	{
322
	{
Lines 396-415 Link Here
396
				_wizard.getPropertyImportWizardPage().setPageComplete(true);
392
				_wizard.getPropertyImportWizardPage().setPageComplete(true);
397
				String wsdlFilePath = getWSDLFilePath();
393
				String wsdlFilePath = getWSDLFilePath();
398
				IFile wsdlFile = EclipseUtils.getIFile(wsdlFilePath);
394
				IFile wsdlFile = EclipseUtils.getIFile(wsdlFilePath);
399
				CapabilityDefinition capabilityDefinition = WsdlUtils
395
				_importedWsdlDefinition = getWsdlDefinition(wsdlFile);
400
						.getCapabilityDefinition(wsdlFile);
401
				Definition wsdlDefinition = capabilityDefinition
402
						.getDefinition();
403
				OperationImportWizardPage page = _wizard
396
				OperationImportWizardPage page = _wizard
404
						.getOperationImportWizardPage();
397
						.getOperationImportWizardPage();
405
				page.setWSDLDefinition(wsdlDefinition);
398
				page.setWSDLDefinition(_importedWsdlDefinition);
406
				page.setImportedWsdlURI(URI.createPlatformResourceURI(wsdlFile.getFullPath().toString()));
399
				_importedWsdlURI = URI.createPlatformResourceURI(wsdlFile.getFullPath().toString());
407
				setPageComplete(true);
400
				setPageComplete(true);
408
				return page;
401
				return page;
409
			}
402
			}
410
			catch (Exception e)
403
			catch (Exception e)
411
			{
404
			{
412
				e.printStackTrace();
405
				WsdmToolingLog.logError(e.getMessage(), e);
413
			}
406
			}
414
		}
407
		}
415
		if (_fromXSD.getSelection())
408
		if (_fromXSD.getSelection())
Lines 428-434 Link Here
428
			}
421
			}
429
			catch (Exception e)
422
			catch (Exception e)
430
			{
423
			{
431
				e.printStackTrace();
424
				WsdmToolingLog.logError(e.getMessage(), e);
432
			}
425
			}
433
		}
426
		}
434
		return super.getNextPage();
427
		return super.getNextPage();
Lines 453-456 Link Here
453
	{
446
	{
454
		return _fromWSDL.getSelection();
447
		return _fromWSDL.getSelection();
455
	}
448
	}
449
	
450
	public URI getImportedWsdlURI()
451
	{
452
		return _importedWsdlURI;
453
	}
454
455
	public Definition getImportedWsdlDefinition()
456
	{
457
		return _importedWsdlDefinition;
458
	}
456
}
459
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyImportWizard.java (-1 / +2 lines)
Lines 28-33 Link Here
28
import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain;
28
import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain;
29
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property;
29
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property;
30
import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages;
30
import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages;
31
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog;
31
import org.eclipse.ui.INewWizard;
32
import org.eclipse.ui.INewWizard;
32
import org.eclipse.ui.IWorkbench;
33
import org.eclipse.ui.IWorkbench;
33
import org.eclipse.xsd.XSDElementDeclaration;
34
import org.eclipse.xsd.XSDElementDeclaration;
Lines 81-87 Link Here
81
		}
82
		}
82
		catch (Exception e)
83
		catch (Exception e)
83
		{
84
		{
84
			e.printStackTrace();
85
			WsdmToolingLog.logError(e.getMessage(), e);
85
		}
86
		}
86
		return false;
87
		return false;
87
	}
88
	}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/imports/xsd/PropertyImportWizardPage.java (-1 / +36 lines)
Lines 126-132 Link Here
126
		// _viewer.expandToLevel(2);
126
		// _viewer.expandToLevel(2);
127
		// Checked the Schemas provided by constructor
127
		// Checked the Schemas provided by constructor
128
		doIntialCheckedElements();
128
		doIntialCheckedElements();
129
		_viewer.setGrayedElements(_existingPropertyNs);
129
		//_viewer.setGrayedElements(_existingPropertyNs);
130
		updateStatus(null);
130
		updateStatus(null);
131
	}
131
	}
132
132
Lines 157-163 Link Here
157
			}
157
			}
158
		}
158
		}
159
159
160
		_viewer.setGrayChecked(event.getElement(), false);
160
		_viewer.setSubtreeChecked(event.getElement(), event.getChecked());
161
		_viewer.setSubtreeChecked(event.getElement(), event.getChecked());
162
		changeParentCheckStatus(event.getElement());
161
		Property[] checkedProperties = getCheckedProperties();
163
		Property[] checkedProperties = getCheckedProperties();
162
		PropertyImportValidator validator = new PropertyImportValidator(
164
		PropertyImportValidator validator = new PropertyImportValidator(
163
				checkedProperties);
165
				checkedProperties);
Lines 173-178 Link Here
173
		}
175
		}
174
		_importedProperties = getSelectedProperties();
176
		_importedProperties = getSelectedProperties();
175
	}
177
	}
178
	
179
	private void changeParentCheckStatus(Object checkedElement)
180
	{
181
		Object parent = _contentProvider.getParent(checkedElement);
182
		if(parent == null)
183
			return;
184
		Object[] childrens = _contentProvider.getChildren(parent);
185
		int checkedChildrensSize = 0;
186
		for(int i=0;i<childrens.length;i++)
187
		{	
188
			if(_viewer.getChecked(childrens[i]))
189
				checkedChildrensSize++;
190
		}
191
		// If all childrens checked, make the parent checked
192
		if(checkedChildrensSize == childrens.length)
193
		{
194
			_viewer.setGrayChecked(parent, false);
195
			_viewer.setChecked(parent, true);
196
			return;
197
		}
198
		// If not all but any one of the childrens checked, make the parent grayed
199
		if(checkedChildrensSize>0)
200
		{
201
			_viewer.setGrayChecked(parent, true);
202
			return;
203
		}
204
		// If none of them is checked, then make the parent unchecked
205
		if(checkedChildrensSize == 0)
206
		{
207
			_viewer.setGrayChecked(parent, false);
208
			return;
209
		}
210
	}
176
211
177
	private void updateStatus(String message)
212
	private void updateStatus(String message)
178
	{
213
	{
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/internal/ImportPropertyCommand.java (-18 lines)
Lines 88-111 Link Here
88
	{
88
	{
89
		// Get the location for Imported XSD Schema in local drive format
89
		// Get the location for Imported XSD Schema in local drive format
90
		XSDSchema importSchema = importedProperty.getElement().getSchema();
90
		XSDSchema importSchema = importedProperty.getElement().getSchema();
91
		// String schemaLocation =
92
		// XsdUtils.getLocalSystemSchemaLocation(importSchema);
93
94
		// Get the location for capability file
95
		// String capFileLocation = null;
96
		// try {
97
		// capFileLocation =
98
		// WsdlUtils.getLocalSystemWSDLLocation(_capabilityDefinition);
99
		// } catch (CoreException e) {
100
		// e.printStackTrace();
101
		// }
102
103
		// Create xsd:import element
104
		// String importSchemaLocation = EclipseUtils.getRelativePath(
105
		// capFileLocation, schemaLocation, '/');
106
		// XsdUtils.createImportStatement(_resourcePropertyElement.getSchema(),
107
		// importSchema.getTargetNamespace(), importSchemaLocation);
108
109
		XsdUtils.createImportStatement(_resourcePropertyElement.getSchema(),
91
		XsdUtils.createImportStatement(_resourcePropertyElement.getSchema(),
110
				importSchema.getTargetNamespace(), importSchema.eResource()
92
				importSchema.getTargetNamespace(), importSchema.eResource()
111
						.getURI().toString());
93
						.getURI().toString());
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/pages/operation/internal/NewParameterDialog.java (+7 lines)
Lines 218-223 Link Here
218
				paramName = nameGenerator.getNextName();
218
				paramName = nameGenerator.getNextName();
219
			}
219
			}
220
		}
220
		}
221
		else if(paramName == null)
222
			paramName = "";
223
		
221
		_paramName.setText(paramName);
224
		_paramName.setText(paramName);
222
225
223
		DataTypesCollection instance = DataTypesCollection.getInstance();
226
		DataTypesCollection instance = DataTypesCollection.getInstance();
Lines 249-254 Link Here
249
			for (int i = 0; i < _paramList.size(); i++)
252
			for (int i = 0; i < _paramList.size(); i++)
250
			{
253
			{
251
				InputParameter param = (InputParameter) _paramList.get(i);
254
				InputParameter param = (InputParameter) _paramList.get(i);
255
				if(param.getXSDElementDeclaration().getName() == null)
256
					continue;
252
				if (param.getXSDElementDeclaration().getName().equals(
257
				if (param.getXSDElementDeclaration().getName().equals(
253
						newParamName))
258
						newParamName))
254
					instances++;
259
					instances++;
Lines 260-265 Link Here
260
		for (int i = 0; i < _paramList.size(); i++)
265
		for (int i = 0; i < _paramList.size(); i++)
261
		{
266
		{
262
			InputParameter param = (InputParameter) _paramList.get(i);
267
			InputParameter param = (InputParameter) _paramList.get(i);
268
			if(param.getXSDElementDeclaration().getName() == null)
269
				continue;
263
			if (param.getXSDElementDeclaration().getName().equals(newParamName))
270
			if (param.getXSDElementDeclaration().getName().equals(newParamName))
264
				return true;
271
				return true;
265
		}
272
		}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/internal/ImportOperationCommand.java (-38 / +91 lines)
Lines 13-25 Link Here
13
package org.eclipse.tptp.wsdm.tooling.editor.capability.command.operation.internal;
13
package org.eclipse.tptp.wsdm.tooling.editor.capability.command.operation.internal;
14
14
15
import java.util.ArrayList;
15
import java.util.ArrayList;
16
import java.util.Arrays;
16
import java.util.Iterator;
17
import java.util.Iterator;
17
import java.util.LinkedList;
18
import java.util.LinkedList;
18
import java.util.List;
19
import java.util.List;
19
import java.util.Map;
20
import java.util.Map;
21
import java.util.Vector;
20
22
21
import javax.wsdl.Definition;
23
import javax.wsdl.Definition;
22
import javax.wsdl.Fault;
24
import javax.wsdl.Fault;
25
import javax.wsdl.Import;
23
import javax.wsdl.Input;
26
import javax.wsdl.Input;
24
import javax.wsdl.Message;
27
import javax.wsdl.Message;
25
import javax.wsdl.Operation;
28
import javax.wsdl.Operation;
Lines 39-44 Link Here
39
import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition;
42
import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition;
40
import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages;
43
import org.eclipse.tptp.wsdm.tooling.nls.messages.capability.imports.internal.Messages;
41
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils;
44
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils;
45
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmConstants;
42
import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils;
46
import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils;
43
import org.eclipse.xsd.XSDElementDeclaration;
47
import org.eclipse.xsd.XSDElementDeclaration;
44
import org.eclipse.xsd.XSDImport;
48
import org.eclipse.xsd.XSDImport;
Lines 54-81 Link Here
54
public class ImportOperationCommand
58
public class ImportOperationCommand
55
{
59
{
56
	private CapabilityDefinition _capabilityDefinition;
60
	private CapabilityDefinition _capabilityDefinition;
61
	private Definition _importDefinition;
57
	private Definition _definition;
62
	private Definition _definition;
58
	private Operation[] _importedOperations;
63
	private Operation[] _importedOperations;
59
	private URI _importedWsdlURI;
64
	private URI _importedWsdlURI;
60
	private List _newOperations;
65
	private List _newOperations;
61
	private IProgressMonitor _monitor;
66
	private IProgressMonitor _monitor;
62
	private XSDSchema[] _importedWsdlSchemas = new XSDSchema[0];
67
	private XSDSchema[] _importedWsdlSchemas = new XSDSchema[0];
68
	private QName WSA_ACTION_QNAME = new QName(WsdmConstants.WSA_URI,
69
			WsdmConstants.WSA_ACTION_NAME);
63
70
64
	/**
71
	/**
65
	 * Creates a new object of this class.
72
	 * Creates a new object of this class.
66
	 */
73
	 */
67
	public ImportOperationCommand(CapabilityDefinition capabilityDefinition,
74
	public ImportOperationCommand(CapabilityDefinition capabilityDefinition,Definition importDefinition,
68
			Operation[] importedOperations, URI importedWsdlURI, IProgressMonitor monitor)
75
			Operation[] importedOperations, URI importedWsdlURI, IProgressMonitor monitor)
69
	{
76
	{
70
		_capabilityDefinition = capabilityDefinition;
77
		_capabilityDefinition = capabilityDefinition;
71
		_definition = _capabilityDefinition.getDefinition();
78
		_definition = _capabilityDefinition.getDefinition();
79
		_importDefinition = importDefinition;
72
		_importedWsdlURI = importedWsdlURI;
80
		_importedWsdlURI = importedWsdlURI;
73
		_importedOperations = importedOperations;
81
		_importedOperations = importedOperations;
74
		_newOperations = new LinkedList();
82
		_newOperations = new LinkedList();
75
		_monitor = monitor;
83
		_monitor = monitor;
76
		_importedWsdlSchemas = loadSchemas(_importedWsdlURI);
84
		_importedWsdlSchemas = loadSchemas();
77
		XSDSchema[] capabilityWsdlSchemas = _capabilityDefinition
85
		//XSDSchema[] capabilityWsdlSchemas = _capabilityDefinition.getXSDSchemas();
78
				.getXSDSchemas();
79
		// TODO
86
		// TODO
80
		/*
87
		/*
81
		 * if(capabilityWsdlSchemas == null) // No wsdl types defined { Types
88
		 * if(capabilityWsdlSchemas == null) // No wsdl types defined { Types
Lines 90-99 Link Here
90
	/**
97
	/**
91
	 * Creates a new object of this class.
98
	 * Creates a new object of this class.
92
	 */
99
	 */
93
	public ImportOperationCommand(CapabilityDefinition capabilityDefinition,
100
	public ImportOperationCommand(CapabilityDefinition capabilityDefinition,Definition importDefinition,
94
			Operation[] importedOperations, URI importedWsdlURI)
101
			Operation[] importedOperations, URI importedWsdlURI)
95
	{
102
	{
96
		this(capabilityDefinition, importedOperations, importedWsdlURI, null);
103
		this(capabilityDefinition, importDefinition, importedOperations, importedWsdlURI, null);
97
	}
104
	}
98
	
105
	
99
	/**
106
	/**
Lines 103-108 Link Here
103
	{
110
	{
104
		_monitor.beginTask(Messages.IMPORTING_OPERATIONS,
111
		_monitor.beginTask(Messages.IMPORTING_OPERATIONS,
105
				_importedOperations.length);
112
				_importedOperations.length);
113
		_definition.addNamespace(WsdmConstants.WSA_PREFIX,
114
				WsdmConstants.WSA_URI);
106
		for (int i = 0; i < _importedOperations.length; i++)
115
		for (int i = 0; i < _importedOperations.length; i++)
107
		{
116
		{
108
			String taskName = Messages.bind(Messages.IMPORTING_OPERATION,
117
			String taskName = Messages.bind(Messages.IMPORTING_OPERATION,
Lines 142-157 Link Here
142
		newInput.setMessage(newMessage);
151
		newInput.setMessage(newMessage);
143
		_capabilityDefinition.addMessage(newMessage);
152
		_capabilityDefinition.addMessage(newMessage);
144
153
145
		// TODO
154
		String action = getAction(newInput.getMessage());
146
		/*
155
		newInput.setExtensionAttribute(WSA_ACTION_QNAME, action);		
147
		 * String opName = importedOperation.getName(); opName =
156
	}
148
		 * opName.substring(0, 1).toUpperCase() + opName.substring(1); String
157
	
149
		 * tns = _capabilityDefinition.getTargetNamespace();
158
	private String getAction(Message message)
150
		 * if(!tns.endsWith("/")) tns = tns+"/"; String action =
159
	{
151
		 * tns+opName+"Request";
160
		String uri = message.getQName().getNamespaceURI();
152
		 * newInput.getElement().setAttributeNS(WsdmConstants.WSA_URI,
161
		String name = message.getQName().getLocalPart();
153
		 * WsdmConstants.WSA_ACTION_NAME, action);
162
		name = name.substring(0, 1).toUpperCase() + name.substring(1);
154
		 */
163
		return uri + "/" + name;
155
	}
164
	}
156
165
157
	private void createNewOperationOutput(Operation newOperation,
166
	private void createNewOperationOutput(Operation newOperation,
Lines 168-184 Link Here
168
		Message newMessage = createNewMessage(importedMessage);
177
		Message newMessage = createNewMessage(importedMessage);
169
		newOutput.setMessage(newMessage);
178
		newOutput.setMessage(newMessage);
170
		_capabilityDefinition.addMessage(newMessage);
179
		_capabilityDefinition.addMessage(newMessage);
171
180
		
172
		// TODO
181
		String action = getAction(newOutput.getMessage());
173
		/*
182
		newOutput.setExtensionAttribute(WSA_ACTION_QNAME, action);		
174
		 * String opName = importedOperation.getName(); opName =
175
		 * opName.substring(0, 1).toUpperCase() + opName.substring(1); String
176
		 * tns = _capabilityDefinition.getTargetNamespace();
177
		 * if(!tns.endsWith("/")) tns = tns+"/"; String action =
178
		 * tns+opName+"Response";
179
		 * newOutput.getElement().setAttributeNS(WsdmConstants.WSA_URI,
180
		 * WsdmConstants.WSA_ACTION_NAME, action);
181
		 */
182
	}
183
	}
183
184
184
	private void createNewOperationFaults(Operation newOperation,
185
	private void createNewOperationFaults(Operation newOperation,
Lines 220-243 Link Here
220
		  Part part = definition.createPart();
221
		  Part part = definition.createPart();
221
		  message.addPart(part); 
222
		  message.addPart(part); 
222
		  Part importedPart = (Part)importedMessage.getParts().values().iterator().next();
223
		  Part importedPart = (Part)importedMessage.getParts().values().iterator().next();
223
		  XSDSchema importedPartSchema = getImportedWSDLSchema(importedPart.getElementName().getNamespaceURI());
224
		  importSchemaForElement(importedPartSchema); 
225
		  String xsdNS = importedPart.getElementName().getNamespaceURI();
226
		  String elementName = importedPart.getElementName().getLocalPart();
227
		  XSDSchema elementSchema = _capabilityDefinition.getSchema(xsdNS); 
228
		  XSDElementDeclaration element = XsdUtils.getXSDElementDeclarationOfName(elementSchema, elementName);
229
		  _capabilityDefinition.createOrFindPrefix(element.getTargetNamespace(), null);
230
		  part.setName(importedPart.getName());
224
		  part.setName(importedPart.getName());
231
		  part.setElementName(new QName(xsdNS, elementName)); 
225
		  if(importedPart.getElementName()!=null)
226
		  {
227
			  XSDSchema importedPartSchema = getImportedWSDLSchema(importedPart.getElementName().getNamespaceURI());
228
			  importSchemaForElement(importedPartSchema); 
229
			  String xsdNS = importedPart.getElementName().getNamespaceURI();
230
			  String elementName = importedPart.getElementName().getLocalPart();
231
			  XSDSchema elementSchema = _capabilityDefinition.getSchema(xsdNS); 
232
			  XSDElementDeclaration element = XsdUtils.getXSDElementDeclarationOfName(elementSchema, elementName);
233
			  _capabilityDefinition.createOrFindPrefix(element.getTargetNamespace(), null);			  
234
			  part.setElementName(new QName(xsdNS, elementName));  
235
		  }
236
		  else if(importedPart.getTypeName()!=null)
237
		  {
238
			  String xsdNS = importedPart.getTypeName().getNamespaceURI();
239
			  String localName = importedPart.getTypeName().getLocalPart();
240
			  part.setTypeName(new QName(xsdNS, localName));
241
		  }
232
		  return message;
242
		  return message;
233
	}
243
	}
234
	
244
	
235
	private XSDSchema getImportedWSDLSchema(String namespace)
245
	private XSDSchema getImportedWSDLSchema(String namespace)
236
	{
246
	{
237
		for(int i=0;i<_importedWsdlSchemas.length;i++)
247
		for(int i=0;i<_importedWsdlSchemas.length;i++)
238
		{
239
			if(_importedWsdlSchemas[i].getTargetNamespace().equals(namespace))
248
			if(_importedWsdlSchemas[i].getTargetNamespace().equals(namespace))
240
				return _importedWsdlSchemas[i];
249
				return _importedWsdlSchemas[i];
250
		
251
		for(int i=0;i<_importedWsdlSchemas.length;i++)
252
		{
253
			XSDImport theImports[] = XsdUtils.getAllXSDImports(_importedWsdlSchemas[i]);
254
			for(int j=0;j<theImports.length;j++)
255
				if(theImports[j].getNamespace().equals(namespace))
256
					return theImports[j].getResolvedSchema();
241
		}
257
		}
242
		return null;
258
		return null;
243
	}
259
	}
Lines 272-287 Link Here
272
		XSDSchema copySchema = (XSDSchema) schema.cloneConcreteComponent(true,
288
		XSDSchema copySchema = (XSDSchema) schema.cloneConcreteComponent(true,
273
				false);
289
				false);
274
		List contents = copySchema.getContents();
290
		List contents = copySchema.getContents();
291
		List includes = new LinkedList();
292
		List imports = new LinkedList();
275
		for (int i = 0; i < contents.size(); i++)
293
		for (int i = 0; i < contents.size(); i++)
276
		{
294
		{
277
			if (contents.get(i) instanceof XSDInclude)
295
			if (contents.get(i) instanceof XSDInclude)
278
				contents.remove(i);
296
				includes.add(contents.get(i));
279
			else if (contents.get(i) instanceof XSDImport)
297
			else if (contents.get(i) instanceof XSDImport)
280
			{
298
			{
281
				XSDImport theImport = (XSDImport) contents.get(i);
299
				XSDImport theImport = (XSDImport) contents.get(i);				
282
				theImport.setSchemaLocation(null);
300
				theImport.setSchemaLocation(null);
301
				imports.add(theImport);
283
			}
302
			}
284
		}
303
		}
304
		contents.removeAll(includes);
305
		contents.removeAll(imports);
306
		contents.addAll(0, imports);		
285
		copySchema.updateElement(true);
307
		copySchema.updateElement(true);
286
		return copySchema;
308
		return copySchema;
287
	}
309
	}
Lines 292-297 Link Here
292
				.toArray(new Operation[_newOperations.size()]);
314
				.toArray(new Operation[_newOperations.size()]);
293
	}
315
	}
294
	
316
	
317
	private XSDSchema[] loadSchemas()
318
	{
319
		List schemasList = new LinkedList();
320
		XSDSchema[] schemas = loadSchemas(_importedWsdlURI);
321
		schemasList.addAll(Arrays.asList(schemas));
322
		
323
		Map importsMap = _importDefinition.getImports();
324
		if(importsMap == null || importsMap.size() == 0)
325
			return (XSDSchema[]) schemasList.toArray(new XSDSchema[0]);
326
		
327
		Iterator it = importsMap.values().iterator();
328
		while(it.hasNext())
329
		{
330
			Object object = it.next();
331
			if(object instanceof Vector)
332
			{
333
				Vector vector = (Vector) object;
334
				for(int i=0;i<vector.size();i++)
335
				{
336
					Import wsdlImport = (Import) vector.get(i);
337
					String locationURI = wsdlImport.getLocationURI();
338
					URI wsdlURI = URI.createURI(_importedWsdlURI.trimSegments(1).toString()+"/"+locationURI);
339
					XSDSchema[] importedSchemas = loadSchemas(wsdlURI);
340
					schemasList.addAll(Arrays.asList(importedSchemas));
341
				}
342
			}
343
		}
344
		
345
		return (XSDSchema[]) schemasList.toArray(new XSDSchema[0]);
346
	}
347
	
295
	private XSDSchema[] loadSchemas(URI uri)
348
	private XSDSchema[] loadSchemas(URI uri)
296
	{
349
	{
297
		// Get a ResourceSet describing the XSD in the WSDL
350
		// Get a ResourceSet describing the XSD in the WSDL

Return to bug 165544