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 173433 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/ServiceGroupInspector.java (-303 / +91 lines)
Lines 13-27 Link Here
13
package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional;
13
package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional;
14
14
15
import java.io.ByteArrayInputStream;
15
import java.io.ByteArrayInputStream;
16
import java.io.IOException;
17
import java.io.InputStream;
16
import java.io.InputStream;
18
import java.net.URL;
19
import java.util.ArrayList;
17
import java.util.ArrayList;
20
import java.util.HashMap;
18
import java.util.HashMap;
21
import java.util.Iterator;
22
import java.util.List;
19
import java.util.List;
23
20
24
import org.apache.muse.tools.Activator;
21
import javax.xml.namespace.QName;
22
23
import org.apache.muse.util.xml.XmlUtils;
24
import org.apache.muse.ws.addressing.soap.SoapFault;
25
import org.apache.muse.ws.resource.sg.WssgConstants;
25
import org.apache.ws.muse.descriptor.CapabilityType;
26
import org.apache.ws.muse.descriptor.CapabilityType;
26
import org.apache.ws.muse.descriptor.DescriptorFactory;
27
import org.apache.ws.muse.descriptor.DescriptorFactory;
27
import org.apache.ws.muse.descriptor.DocumentRoot;
28
import org.apache.ws.muse.descriptor.DocumentRoot;
Lines 31-66 Link Here
31
import org.apache.ws.muse.descriptor.ResourceTypeType;
32
import org.apache.ws.muse.descriptor.ResourceTypeType;
32
import org.apache.ws.muse.descriptor.WsdlType;
33
import org.apache.ws.muse.descriptor.WsdlType;
33
import org.eclipse.core.resources.IFile;
34
import org.eclipse.core.resources.IFile;
34
import org.eclipse.core.runtime.CoreException;
35
import org.eclipse.core.runtime.NullProgressMonitor;
35
import org.eclipse.core.runtime.NullProgressMonitor;
36
import org.eclipse.emf.common.util.URI;
36
import org.eclipse.emf.common.util.URI;
37
import org.eclipse.emf.ecore.EStructuralFeature;
38
import org.eclipse.emf.ecore.resource.Resource;
37
import org.eclipse.emf.ecore.resource.Resource;
39
import org.eclipse.emf.ecore.resource.ResourceSet;
38
import org.eclipse.emf.ecore.resource.ResourceSet;
40
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
39
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
41
import org.eclipse.emf.ecore.util.BasicExtendedMetaData;
42
import org.eclipse.emf.ecore.util.ExtendedMetaData;
43
import org.eclipse.emf.ecore.util.FeatureMap;
44
import org.eclipse.emf.ecore.xml.type.AnyType;
45
import org.eclipse.emf.ecore.xml.type.XMLTypeFactory;
46
import org.eclipse.tptp.wsdm.model.MetadataDescriptor;
47
import org.eclipse.tptp.wsdm.tooling.editor.capability.util.internal.MetaDataUtils;
48
import org.eclipse.tptp.wsdm.tooling.editor.mrt.servicegroup.utils.internal.ServiceGroupUtils;
49
import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.NewNameGenerator;
40
import org.eclipse.tptp.wsdm.tooling.editor.ui.internal.NewNameGenerator;
50
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability;
41
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability;
51
import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType;
42
import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType;
52
import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceTypeFactory;
43
import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceTypeFactory;
53
import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.MembershipContentRuleType;
44
import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.MembershipContentRuleType;
54
import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.InitialValuesType;
45
import org.eclipse.tptp.wsdm.tooling.util.internal.CustomMrtResourceFactoryImpl;
55
import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.MetadataDescriptorFactory;
56
import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.PropertyType;
57
import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.impl.MetadataDescriptorFactoryImpl;
58
import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils;
46
import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils;
59
import org.eclipse.tptp.wsdm.tooling.util.internal.IFile2Capability;
60
import org.eclipse.tptp.wsdm.tooling.util.internal.MrtUtils;
47
import org.eclipse.tptp.wsdm.tooling.util.internal.MrtUtils;
61
import org.eclipse.tptp.wsdm.tooling.util.internal.RmdUtils;
62
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmConstants;
48
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmConstants;
63
import org.eclipse.tptp.wsdm.tooling.util.internal.CustomMrtResourceFactoryImpl;
49
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog;
50
import org.w3c.dom.Document;
51
import org.w3c.dom.Element;
64
/**
52
/**
65
 * This class analyzes the given manageable resource type and provide an extra
53
 * This class analyzes the given manageable resource type and provide an extra
66
 * resource type for muse descriptor (ServiceGroupEntry), if manageable
54
 * resource type for muse descriptor (ServiceGroupEntry), if manageable
Lines 76-89 Link Here
76
	
64
	
77
	private ResourceTypeType _serviceGroupEntryResorceType;
65
	private ResourceTypeType _serviceGroupEntryResorceType;
78
	
66
	
79
	private ManageableResourceType _mrt;
80
	
81
	private ExtendedMetaData _extendedMetaData;
82
	
83
	private ManageableResourceType _serviceGroupEntrymrt;
67
	private ManageableResourceType _serviceGroupEntrymrt;
84
	
68
	
85
	private List _fileLocation ;
86
	
87
	private HashMap _prefixNamespaceMap;
69
	private HashMap _prefixNamespaceMap;
88
	
70
	
89
	/**
71
	/**
Lines 95-102 Link Here
95
	public ServiceGroupInspector(ManageableResourceType mrt,DocumentRoot root)
77
	public ServiceGroupInspector(ManageableResourceType mrt,DocumentRoot root)
96
	{
78
	{
97
		_root = root;
79
		_root = root;
98
		_mrt = mrt;
99
		_extendedMetaData = createExtendedMetaData();
100
	}
80
	}
101
81
102
	/**
82
	/**
Lines 107-152 Link Here
107
	public ResourceTypeType inspect(Capability[] mrtCapabilities) 
87
	public ResourceTypeType inspect(Capability[] mrtCapabilities) 
108
	{
88
	{
109
		
89
		
110
		for(int i =0;i<mrtCapabilities.length;i++)
90
		if(hasServiceGroupCapabilities(mrtCapabilities))
111
		{
91
			return createServiceGroupEntryResourceType();
112
			if(hasServiceGroupCapabilities(mrtCapabilities))
113
			{
114
					addMandatoryFiles();
115
				return createServiceGroupEntryResourceType();
116
			}
117
		}
118
		
119
		return null;
92
		return null;
120
	}
93
	}
121
	
94
	
122
	private void  addMandatoryFiles() 
123
	{
124
		_fileLocation = new ArrayList();
125
		boolean hasSGCapability = workspaceHasServiceGroupCapability();
126
		boolean hasSGRmd = workspaceHasServiceGroupRMD();
127
		try
128
		{
129
			if(hasSGCapability && hasSGRmd)
130
			{
131
				copyMemberRulesToRMD();
132
				
133
			}else if(hasSGCapability && !hasSGRmd)
134
			{
135
				createRMDFile();
136
				copyMemberRulesToRMD();
137
			}
138
			else
139
			{
140
				createServiceGroupCapability();
141
				createRMDFile();
142
				copyMemberRulesToRMD();
143
			}
144
		}catch (Exception ex)
145
		{
146
			ex.printStackTrace();
147
		}
148
149
	}
150
	private boolean hasServiceGroupCapabilities(Capability[] mrtCapabilities)
95
	private boolean hasServiceGroupCapabilities(Capability[] mrtCapabilities)
151
	{
96
	{
152
		boolean hasServiceGroupCapability = false;
97
		boolean hasServiceGroupCapability = false;
Lines 163-217 Link Here
163
		return hasServiceGroupCapability && hasServiceGroupRegistration;
108
		return hasServiceGroupCapability && hasServiceGroupRegistration;
164
	}
109
	}
165
110
166
	private void createRMDFile()
167
	{
168
		URL serviceGroupRMDURL = Activator.getDefault().getBundle().getEntry("artifacts/resourceTypes/ServiceGroupCapability.rmd");
169
		try {
170
			InputStream is = serviceGroupRMDURL.openStream();
171
			IFile serviceGroupRMDIFile = EclipseUtils.getIFile(_mrtParentDirName+"/ServiceGroupCapability.rmd");
172
			
173
			if(!serviceGroupRMDIFile.exists())
174
			{
175
				serviceGroupRMDIFile.create(is, true, new NullProgressMonitor());
176
			}
177
			else
178
			{
179
				serviceGroupRMDIFile.setContents(is, IFile.FORCE, new NullProgressMonitor());
180
			}
181
				
182
			_fileLocation.add(serviceGroupRMDIFile);
183
		} catch (Exception e) {
184
			// TODO Auto-generated catch block
185
			e.printStackTrace();
186
		}
187
		
188
	}
189
190
	private IFile createServiceGroupCapability()
191
	{
192
		try {
193
			URL sgCapabilityURL = Activator.getDefault().getBundle().getEntry("artifacts/resourceTypes/ServiceGroupCapability.wsdl");
194
			InputStream is = sgCapabilityURL.openStream();
195
			IFile sgCapabilityIFile = EclipseUtils.getIFile(_mrtParentDirName+"/ServiceGroupCapability.mcap");
196
			if(!sgCapabilityIFile.exists())
197
			{
198
				sgCapabilityIFile.create(is, true, new NullProgressMonitor());
199
			}
200
			else
201
			{
202
				sgCapabilityIFile.setContents(is, IFile.FORCE, new NullProgressMonitor());
203
			}
204
			
205
			_fileLocation.add(sgCapabilityIFile);
206
			
207
			return sgCapabilityIFile;
208
		} catch (Exception e) {
209
			// TODO Auto-generated catch block
210
			e.printStackTrace();
211
		}
212
		return null;
213
	}
214
	
215
	/**
111
	/**
216
	 * Returns the initial instances
112
	 * Returns the initial instances
217
	 * @return InitialInstancesType[]
113
	 * @return InitialInstancesType[]
Lines 242-256 Link Here
242
	{
138
	{
243
		createServiceGroupEntryMrt();
139
		createServiceGroupEntryMrt();
244
		_serviceGroupEntryResorceType = createServiceGroupEntryMuseResourceType();
140
		_serviceGroupEntryResorceType = createServiceGroupEntryMuseResourceType();
245
		_mrt.getImplements().remove(WsdmConstants.SERVICE_GROUP_CAPABILITY_LOCATION);
246
		_mrt.getImplements().add("platform:/resource"+_mrtParentDirName+"/ServiceGroupCapability.mcap");
247
		saveMRTFile(_mrt);	
248
		return _serviceGroupEntryResorceType;
141
		return _serviceGroupEntryResorceType;
249
	}
142
	}
250
	
143
	
251
	private void createServiceGroupEntryMrt()
144
	private void createServiceGroupEntryMrt()
252
	{
145
	{
253
		 //_serviceGroupEntrymrt = ManageableResourceTypeFactory.eINSTANCE.createManageableResourceType();
254
		 org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.DocumentRoot documentRoot = ManageableResourceTypeFactory.eINSTANCE.createDocumentRoot();
146
		 org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.DocumentRoot documentRoot = ManageableResourceTypeFactory.eINSTANCE.createDocumentRoot();
255
		 _serviceGroupEntrymrt = ManageableResourceTypeFactory.eINSTANCE.createManageableResourceType();
147
		 _serviceGroupEntrymrt = ManageableResourceTypeFactory.eINSTANCE.createManageableResourceType();
256
		 documentRoot.setManageableResource(_serviceGroupEntrymrt);
148
		 documentRoot.setManageableResource(_serviceGroupEntrymrt);
Lines 322-434 Link Here
322
		return resourceType;
214
		return resourceType;
323
	}
215
	}
324
	
216
	
325
	private boolean workspaceHasServiceGroupCapability()
326
	{
327
		List fileList = ServiceGroupUtils.getFilesFromDirectory(_mrtParentDirName);
328
		for(Iterator iter = fileList.iterator();iter.hasNext();)
329
		{
330
			IFile file = (IFile) iter.next();
331
			if(file.getFileExtension() == "mcap")
332
			{
333
				try
334
				{
335
					IFile2Capability file2Capability = new IFile2Capability(file);
336
					Capability capability = file2Capability.getCapability();
337
					if(capability.getNamespace().equals(WsdmConstants.SERVICE_GROUP_NS))
338
					{
339
						return true;
340
					}
341
				}catch(Exception e)
342
				{
343
					continue;
344
				}
345
			}
346
		}
347
		return false;
348
	}
349
	
350
	private boolean workspaceHasServiceGroupRMD()
351
	{
352
		List fileList = ServiceGroupUtils.getFilesFromDirectory(_mrtParentDirName);
353
		for(Iterator iter = fileList.iterator();iter.hasNext();)
354
		{
355
			IFile file = (IFile) iter.next();
356
			if(file.getFileExtension() == "rmd")
357
			{
358
				try
359
				{
360
					if(RmdUtils.getDocumentRoot(file).getDefinitions().getTargetNamespace().equals(WsdmConstants.SERVICE_GROUP_NS))
361
						return true;
362
				}catch(Exception e)
363
				{
364
					continue;
365
				}
366
			}
367
		}
368
		return false;
369
	}
370
	
371
	private void copyMemberRulesToRMD() throws CoreException
372
	{
373
		
374
		try {
375
		
376
			IFile file = EclipseUtils.getIFile(_mrtParentDirName+"/ServiceGroupCapability.mcap");
377
			IFile2Capability file2Capability = new IFile2Capability(file);
378
			Capability sgCapability = file2Capability.getCapability();
379
			MetadataDescriptor descriptor = sgCapability.getMetadata();
380
			MetadataDescriptorFactory _rmdFactory = new MetadataDescriptorFactoryImpl();
381
		
382
			
383
			List memberShipContentRuleList = _mrt.getMembershipContentRule();
384
			InitialValuesType initialValuesType = _rmdFactory.createInitialValuesType();
385
			
386
			for(int i = 0; i<memberShipContentRuleList.size();i++)
387
			{
388
				FeatureMap fm = initialValuesType.getAny();
389
				String namespace = WsdmConstants.SERVICE_GROUP_NS;
390
				String name = "MembershipContentRule";
391
				_prefixNamespaceMap = new HashMap();
392
				AnyType anyType = XMLTypeFactory.eINSTANCE.createAnyType();
393
				String xmlAttribute="";
394
				String xmlNamespace = "";
395
				String tns="";
396
				MembershipContentRuleType rule = (MembershipContentRuleType) memberShipContentRuleList.get(i);
397
				for(Iterator iter = rule.getContentElements().iterator();iter.hasNext();)
398
				{
399
					String contentElements = (String)iter.next();
400
					tns = getNamespace(contentElements);
401
					String localName = getLocalName(contentElements);
402
					preparePrfixNamespaceMap(tns);
403
					if(xmlAttribute.length() !=0)
404
						xmlAttribute =  xmlAttribute + " " + (String)_prefixNamespaceMap.get(tns)+":"+ localName;
405
					else
406
						xmlAttribute =(String)_prefixNamespaceMap.get(tns)+":"+ localName;
407
					String xmlns = "xmlns:" + _prefixNamespaceMap.get(tns);
408
					EStructuralFeature pfx1Attribute = _extendedMetaData.demandFeature(null, xmlns, false);  
409
					anyType.eSet(pfx1Attribute, tns); 
410
				} 
411
				EStructuralFeature memberShipContentRule =  _extendedMetaData.demandFeature(namespace,name, true);
412
				fm.add(memberShipContentRule, anyType);
413
				EStructuralFeature contentElementsAttribute = _extendedMetaData.demandFeature(null, "ContentElements", false); 
414
				anyType.eSet(contentElementsAttribute, xmlAttribute);
415
			}
416
		
417
			
418
			PropertyType propertyType = descriptor.getPropertyMetadata("MembershipContentRule", WsdmConstants.SERVICE_GROUP_NS);
419
			propertyType.setInitialValues(initialValuesType);
420
			MetaDataUtils.save(descriptor, new NullProgressMonitor());
421
			
422
		} catch (Exception e){
423
			e.printStackTrace();
424
		}
425
	
426
	}
427
	
428
	private String getNamespace(String contentElement)
217
	private String getNamespace(String contentElement)
429
	{
218
	{
430
		return contentElement.substring(1,contentElement.lastIndexOf('}'));
219
		return contentElement.substring(1,contentElement.lastIndexOf('}'));
431
	}
220
	}
221
	
432
	private void preparePrfixNamespaceMap(String contentElement)
222
	private void preparePrfixNamespaceMap(String contentElement)
433
	{
223
	{
434
		if(!_prefixNamespaceMap.containsKey(contentElement))
224
		if(!_prefixNamespaceMap.containsKey(contentElement))
Lines 455-467 Link Here
455
	{
245
	{
456
		return namespace.substring(namespace.lastIndexOf('}')+1);
246
		return namespace.substring(namespace.lastIndexOf('}')+1);
457
	}
247
	}
458
	private ExtendedMetaData createExtendedMetaData()
248
	
459
	{
460
		ResourceSet resourceSet = new ResourceSetImpl();
461
		ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(
462
				resourceSet.getPackageRegistry());
463
		return extendedMetaData;
464
	}
465
	/**
249
	/**
466
	 * This method will returns the extra generated ManageableResourceType object equivalent to ServiceGroupEntry.
250
	 * This method will returns the extra generated ManageableResourceType object equivalent to ServiceGroupEntry.
467
	 */
251
	 */
Lines 482-572 Link Here
482
	 */
266
	 */
483
	public void persistArtifacts()
267
	public void persistArtifacts()
484
	{
268
	{
485
		ResourceSet rs = new ResourceSetImpl();
269
		try{
486
		byte[] rawNewMRT = MrtUtils.serializeMRT(_serviceGroupEntrymrt, rs, URI
270
			ResourceSet rs = new ResourceSetImpl();
487
				.createURI("dummy.xml"), true);
271
			rs.getResourceFactoryRegistry().getExtensionToFactoryMap()
488
		InputStream stream = new ByteArrayInputStream(rawNewMRT);
272
			.put(Resource.Factory.Registry.DEFAULT_EXTENSION, new CustomMrtResourceFactoryImpl());
489
273
			String serviceGroupMrt = _mrtParentDirName + "/"+ "ServiceGroupEntry.mrt";
490
		try
274
			URI uri = URI.createPlatformResourceURI(serviceGroupMrt);
491
		{
275
			byte[] rawNewMRT = MrtUtils.serializeMRT(_serviceGroupEntrymrt, rs, uri, true);
492
			String serviceGroupMrt = _mrtParentDirName + "/"
276
			InputStream stream = new ByteArrayInputStream(rawNewMRT);			
493
					+ "ServiceGroupEntry.mrt";
277
			IFile subManagerMrtFile = EclipseUtils.getIFile(serviceGroupMrt);
494
			IFile serviceGroupMrtFile = EclipseUtils.getIFile(serviceGroupMrt);
278
			if (subManagerMrtFile.exists())
495
			if (serviceGroupMrtFile.exists())
496
			{
279
			{
497
				serviceGroupMrtFile.setContents(stream, true, true,
280
				subManagerMrtFile.setContents(stream, true, true,
498
						new NullProgressMonitor());
281
				new NullProgressMonitor());
499
			}
282
			}
500
			else
283
			else
501
			{
284
			{
502
				serviceGroupMrtFile.create(stream, true,
285
				subManagerMrtFile.create(stream, true,
503
						new NullProgressMonitor());
286
				new NullProgressMonitor());
504
			}
505
			try
506
			{
507
				stream.close();
508
			}
509
			catch (IOException e)
510
			{
511
				// TODO Log
512
				e.printStackTrace();
513
			}
287
			}
288
			stream.close();			
514
		}
289
		}
515
		catch (CoreException e)
290
		catch(Exception e)
516
		{
291
		{
517
			// TODO Log
518
			e.printStackTrace();
292
			e.printStackTrace();
519
		}
293
		}
520
521
		
522
	}
523
/**
524
 * This method will remove the artifacts which are generated during the code generation time and should not be persisted 
525
 * in the workspace even though user checks the Persisit Artifatcs Button.
526
 */
527
	public void removeArtifacts()
528
	{
529
		if(_mrt.getImplements().contains("platform:/resource"+_mrtParentDirName+"/ServiceGroupCapability.mcap"))
530
		{
531
			_mrt.getImplements().remove("platform:/resource"+_mrtParentDirName+"/ServiceGroupCapability.mcap");
532
			_mrt.getImplements().add(WsdmConstants.SERVICE_GROUP_CAPABILITY_LOCATION);
533
			saveMRTFile(_mrt);
534
			removeFiles(_fileLocation);
535
		}		
536
	}
537
538
	private void saveMRTFile(ManageableResourceType mrt)
539
	{
540
		ResourceSet rs = new ResourceSetImpl();
541
		rs.getResourceFactoryRegistry().getExtensionToFactoryMap()
542
			.put(Resource.Factory.Registry.DEFAULT_EXTENSION, new CustomMrtResourceFactoryImpl());
543
		URI uri = _mrt.eResource().getURI();
544
		byte[] bytes = MrtUtils.serializeMRT(_mrt, rs, uri, false);
545
		try {
546
			IFile mrtFile = EclipseUtils.getIFile(uri.toString());
547
			mrtFile.setContents(new ByteArrayInputStream(bytes), IFile.FORCE, null);
548
		} catch (Exception e) {
549
			e.printStackTrace();
550
		}	
551
	}
294
	}
552
	
295
	
553
	private void removeFiles(List fileLocations) 
554
	{
555
		if(fileLocations != null)
556
		{
557
			for(int i =0;i<fileLocations.size();i++)
558
			{
559
				IFile file = (IFile)fileLocations.get(i);
560
				try {
561
					file.delete(IFile.FORCE, new NullProgressMonitor());
562
				} catch (CoreException e) 
563
				{			
564
					e.printStackTrace();
565
				}
566
			}
567
		}
568
	}
569
570
	/**
296
	/**
571
	 * Inspects the given manageable resource type for servicegroup/relationship kind of resource type and update the given
297
	 * Inspects the given manageable resource type for servicegroup/relationship kind of resource type and update the given
572
	 * merged RMD document for it by having the rules/relationships in it. 
298
	 * merged RMD document for it by having the rules/relationships in it. 
Lines 574-578 Link Here
574
	public void inspectMetadata(ManageableResourceType mrt,
300
	public void inspectMetadata(ManageableResourceType mrt,
575
			org.apache.muse.ws.resource.metadata.MetadataDescriptor rmd) 
301
			org.apache.muse.ws.resource.metadata.MetadataDescriptor rmd) 
576
	{
302
	{
303
		
304
		_prefixNamespaceMap  = new HashMap();
305
		Capability[] mrtCapabilities = new Capability[0];
306
		try 
307
		{
308
			mrtCapabilities = MrtUtils.getCapabilities(mrt);
309
		} 
310
		catch (Exception e)
311
		{
312
			WsdmToolingLog.logError(e.getMessage(), e);
313
		}
314
		
315
		if(hasServiceGroupCapabilities(mrtCapabilities))
316
		{
317
			List membershipContentRule = mrt.getMembershipContentRule();
318
			List initialValues = new ArrayList();
319
			for(int i=0;i<membershipContentRule.size();i++)
320
			{
321
				MembershipContentRuleType rule = (MembershipContentRuleType) membershipContentRule.get(i);
322
				Element value = createMembershipContentRuleElement(rule);
323
				
324
				initialValues.add(value);
325
			}
326
			if(!initialValues.isEmpty());
327
				try 
328
				{
329
					rmd.setInitialValues(new QName(WssgConstants.NAMESPACE_URI,"MembershipContentRule"), initialValues);
330
				} 
331
				catch (SoapFault e) 
332
				{
333
					WsdmToolingLog.logError(e.getMessage(), e);
334
				}
335
		}
336
	}
337
	
338
	private Element createMembershipContentRuleElement(MembershipContentRuleType rule)
339
	{
340
		Document document = XmlUtils.createDocument();
341
		Element membershipContentRuleElement = XmlUtils.createElement(document, new QName(WssgConstants.NAMESPACE_URI,"MembershipContentRule"));
342
		List contentElements = rule.getContentElements();
343
		String contentElementAttribute="";
344
		
345
		for(int i =0 ;i<contentElements.size();i++)
346
		{
347
			String contentElement = (String)contentElements.get(i);
348
			String tns = getNamespace(contentElement);
349
			String localName = getLocalName(contentElement);
350
			preparePrfixNamespaceMap(tns);
351
			
352
			if(contentElementAttribute.length() !=0)
353
				contentElementAttribute =  contentElementAttribute + " " + (String)_prefixNamespaceMap.get(tns)+":"+ localName;
354
			else
355
				contentElementAttribute =(String)_prefixNamespaceMap.get(tns)+":"+ localName;
356
			String  xmlns = "xmlns:" + _prefixNamespaceMap.get(tns);
357
			 membershipContentRuleElement.setAttribute(xmlns,tns );
358
			
359
		}
360
		membershipContentRuleElement.setAttribute("ContentElements",contentElementAttribute );
361
		
362
		return membershipContentRuleElement;
363
		
364
		
577
	}
365
	}
578
}
366
}
(-)src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/MrtPreProcessor.java (-12 lines)
Lines 236-253 Link Here
236
	}
236
	}
237
	
237
	
238
	/**
238
	/**
239
	 * @see MrtInspector#removeArtifacts()
240
	 */
241
	public void removeArtifacts()
242
	{
243
		for(Iterator iter = _allInspectors.iterator();iter.hasNext();)
244
		{
245
			MrtInspector inspector = (MrtInspector) iter.next();
246
			inspector.removeArtifacts();
247
		}
248
	}
249
	
250
	/**
251
	 * Inspects the given manageable resource type for servicegroup/relationship kind of resource type and update the given
239
	 * Inspects the given manageable resource type for servicegroup/relationship kind of resource type and update the given
252
	 * merged RMD document for it by having the rules/relationships in it. 
240
	 * merged RMD document for it by having the rules/relationships in it. 
253
	 */
241
	 */
(-)src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/MRTCodeGenerationDelegate.java (-11 lines)
Lines 30-42 Link Here
30
import org.eclipse.emf.ecore.resource.Resource;
30
import org.eclipse.emf.ecore.resource.Resource;
31
import org.eclipse.emf.ecore.resource.ResourceSet;
31
import org.eclipse.emf.ecore.resource.ResourceSet;
32
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
32
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
33
import org.eclipse.emf.ecore.xmi.XMLResource;
34
import org.eclipse.tptp.wsdm.tooling.editor.dde.util.internal.DdeUtil;
33
import org.eclipse.tptp.wsdm.tooling.editor.dde.util.internal.DdeUtil;
35
import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType;
34
import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType;
36
import org.eclipse.tptp.wsdm.tooling.nls.messages.dde.internal.Messages;
37
import org.eclipse.tptp.wsdm.tooling.util.internal.MrtUtils;
35
import org.eclipse.tptp.wsdm.tooling.util.internal.MrtUtils;
38
import org.eclipse.tptp.wsdm.tooling.util.internal.MyDescriptorResourceFactoryImpl;
36
import org.eclipse.tptp.wsdm.tooling.util.internal.MyDescriptorResourceFactoryImpl;
39
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog;
40
37
41
/**
38
/**
42
 * This class acts as a way during the Code Generation of MRT to capture doing WSDL 
39
 * This class acts as a way during the Code Generation of MRT to capture doing WSDL 
Lines 148-161 Link Here
148
	}
145
	}
149
146
150
	/**
147
	/**
151
	 * @see CodeGenerationDelegate#removeArtifacts()
152
	 */
153
	public void removeArtifacts()
154
	{
155
		_mrtPreProcessor.removeArtifacts();
156
	}
157
158
	/**
159
	 * Inspects the given manageable resource type for servicegroup/relationship kind of resource type and update the given
148
	 * Inspects the given manageable resource type for servicegroup/relationship kind of resource type and update the given
160
	 * merged RMD document for it by having the rules/relationships in it. 
149
	 * merged RMD document for it by having the rules/relationships in it. 
161
	 */
150
	 */
(-)src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/SubscriptionManagerInspector.java (-8 / +3 lines)
Lines 42-47 Link Here
42
import org.eclipse.tptp.wsdm.tooling.util.internal.MrtUtils;
42
import org.eclipse.tptp.wsdm.tooling.util.internal.MrtUtils;
43
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils;
43
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils;
44
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmConstants;
44
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmConstants;
45
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog;
45
46
46
/**
47
/**
47
 * This class analyzes the given manageable resource type and provide an extra
48
 * This class analyzes the given manageable resource type and provide an extra
Lines 295-308 Link Here
295
			}
296
			}
296
			catch (IOException e)
297
			catch (IOException e)
297
			{
298
			{
298
				// TODO Log
299
				WsdmToolingLog.logError(e.getMessage(), e);
299
				e.printStackTrace();
300
			}
300
			}
301
		}
301
		}
302
		catch (CoreException e)
302
		catch (CoreException e)
303
		{
303
		{
304
			// TODO Log
304
			WsdmToolingLog.logError(e.getMessage(), e);
305
			e.printStackTrace();
306
		}
305
		}
307
	}
306
	}
308
307
Lines 322-331 Link Here
322
		return _mrtParentDirName+"/SubscriptionManager.mrt";
321
		return _mrtParentDirName+"/SubscriptionManager.mrt";
323
	}
322
	}
324
323
325
	public void removeArtifacts() 
326
	{
327
	}
328
329
	/**
324
	/**
330
	 * Inspects the given manageable resource type for servicegroup/relationship kind of resource type and update the given
325
	 * Inspects the given manageable resource type for servicegroup/relationship kind of resource type and update the given
331
	 * merged RMD document for it by having the rules/relationships in it. 
326
	 * merged RMD document for it by having the rules/relationships in it. 
(-)src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/NewProjectWizard.java (-1 lines)
Lines 205-211 Link Here
205
			monitor.subTask(Messages.CODE_GEN_STEP4);
205
			monitor.subTask(Messages.CODE_GEN_STEP4);
206
			if(_shouldPersistArtifacts)
206
			if(_shouldPersistArtifacts)
207
				_codeGenerationDelegate.persistArtifacts();
207
				_codeGenerationDelegate.persistArtifacts();
208
			_codeGenerationDelegate.removeArtifacts();
209
			monitor.worked(1);
208
			monitor.worked(1);
210
		}
209
		}
211
		finally
210
		finally
(-)src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/MrtInspector.java (-4 lines)
Lines 60-69 Link Here
60
	 * This method should return the persistance location for extra generated ManageableResourceType object.
60
	 * This method should return the persistance location for extra generated ManageableResourceType object.
61
	 */
61
	 */
62
	String getExtraGeneratedMrtPersistanceLocation();
62
	String getExtraGeneratedMrtPersistanceLocation();
63
	/**
64
	 * This method will remove the file which are created during the code generation such as ServiceGrouypCapability.mcap.
65
	 */
66
	void removeArtifacts();
67
	
63
	
68
	/**
64
	/**
69
	 * Inspects the given manageable resource type for servicegroup/relationship kind of resource type and update the given
65
	 * Inspects the given manageable resource type for servicegroup/relationship kind of resource type and update the given
(-)src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/CodeGenerationDelegate.java (-5 lines)
Lines 44-54 Link Here
44
	void persistArtifacts();
44
	void persistArtifacts();
45
	
45
	
46
	/**
46
	/**
47
	 * Removes the unwanted artifacts from the workspace which are created during code generation like ServiceGroupCapability.mcap and ServiceGroupCapability.rmd
48
	 */
49
	void removeArtifacts();
50
	
51
	/**
52
	 * Inspects the given manageable resource type for servicegroup/relationship kind of resource type and update the given
47
	 * Inspects the given manageable resource type for servicegroup/relationship kind of resource type and update the given
53
	 * merged RMD document for it by having the rules/relationships in it. 
48
	 * merged RMD document for it by having the rules/relationships in it. 
54
	 */
49
	 */
(-)src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/BasicMrtInspector.java (-4 lines)
Lines 116-125 Link Here
116
		return null;
116
		return null;
117
	}
117
	}
118
118
119
	public void removeArtifacts() 
120
	{
121
	}
122
123
	public void inspectMetadata(ManageableResourceType mrt,
119
	public void inspectMetadata(ManageableResourceType mrt,
124
			MetadataDescriptor rmd) 
120
			MetadataDescriptor rmd) 
125
	{
121
	{
(-)src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/RelationshipInspector.java (-8 / +2 lines)
Lines 240-260 Link Here
240
			}
240
			}
241
			catch (IOException e)
241
			catch (IOException e)
242
			{
242
			{
243
				// TODO Log
243
				WsdmToolingLog.logError(e.getMessage(), e);
244
				e.printStackTrace();
245
			}
244
			}
246
		}
245
		}
247
		catch (CoreException e)
246
		catch (CoreException e)
248
		{
247
		{
249
			// TODO Log
248
			WsdmToolingLog.logError(e.getMessage(), e);
250
			e.printStackTrace();
251
		}		
249
		}		
252
	}
250
	}
253
251
254
	public void removeArtifacts() 
255
	{
256
	}
257
258
	public void setMrtParentDirectory(String mrtParentDir) 
252
	public void setMrtParentDirectory(String mrtParentDir) 
259
	{
253
	{
260
		_mrtParentDirName = mrtParentDir;
254
		_mrtParentDirName = mrtParentDir;
(-)src/org/eclipse/tptp/wsdm/tooling/editor/mrt/servicegroup/contentprovider/internal/MembershipContentProvider.java (-75 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 * 	Balan Subramanian (bsubram@us.ibm.com)
10
 *     IBM Corporation - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.tptp.wsdm.tooling.editor.mrt.servicegroup.contentprovider.internal;
14
15
import java.util.List;
16
17
import org.eclipse.jface.viewers.IStructuredContentProvider;
18
import org.eclipse.jface.viewers.LabelProvider;
19
import org.eclipse.jface.viewers.Viewer;
20
import org.eclipse.swt.graphics.Image;
21
/**
22
 * This class is the content provider for the TableViewer int the MemebershipRuleDialog class.
23
 * This will give the list of user selected  QNames.
24
 *
25
 */
26
public class MembershipContentProvider implements IStructuredContentProvider
27
{
28
29
	/**
30
	 * This method will retun the elements of type String to the table viewer.
31
	 */
32
	public Object[] getElements(Object inputElement) 
33
	{
34
		List _qNames = (List) inputElement;
35
		return _qNames.toArray();
36
	}
37
38
	public void dispose() 
39
	{
40
		
41
	}
42
43
	public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
44
	{
45
	}
46
	public QNameContentLabelProvider getQNameContentLabelProvider ()
47
	{
48
		return new QNameContentLabelProvider();
49
	}
50
}
51
/**
52
 *This class is the LabelProvider for the TableViewer in MemebershipRuleDialog class.
53
 *This will return the text to be displayed in the TableViewer.
54
 */
55
class QNameContentLabelProvider extends LabelProvider
56
{
57
58
	
59
	public Image getImage(Object element)
60
	{
61
		
62
		return super.getImage(element);
63
	}
64
65
	/**
66
	 * This method will return the QNames of the elements.
67
	 */
68
	public String getText(Object element)
69
	{
70
		String str = element.toString();
71
		return str.substring(str.lastIndexOf('}')+1, str.length());
72
	}
73
	
74
	
75
}
(-)src/org/eclipse/tptp/wsdm/tooling/codegen/dd/internal/DDCodeGenerationDelegate.java (-12 lines)
Lines 31-45 Link Here
31
import org.eclipse.emf.ecore.resource.Resource;
31
import org.eclipse.emf.ecore.resource.Resource;
32
import org.eclipse.emf.ecore.resource.ResourceSet;
32
import org.eclipse.emf.ecore.resource.ResourceSet;
33
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
33
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
34
import org.eclipse.emf.ecore.xmi.XMLResource;
35
import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.CodeGenerationDelegate;
34
import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.CodeGenerationDelegate;
36
import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.DescriptorHelper;
35
import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.DescriptorHelper;
37
import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.MrtPreProcessor;
36
import org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.MrtPreProcessor;
38
import org.eclipse.tptp.wsdm.tooling.editor.dde.util.internal.DdeUtil;
37
import org.eclipse.tptp.wsdm.tooling.editor.dde.util.internal.DdeUtil;
39
import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType;
38
import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType;
40
import org.eclipse.tptp.wsdm.tooling.nls.messages.dde.internal.Messages;
41
import org.eclipse.tptp.wsdm.tooling.util.internal.MyDescriptorResourceFactoryImpl;
39
import org.eclipse.tptp.wsdm.tooling.util.internal.MyDescriptorResourceFactoryImpl;
42
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog;
43
40
44
/**
41
/**
45
 * A Deployment Descriptor-specifc resolver. This will go through the Deployment
42
 * A Deployment Descriptor-specifc resolver. This will go through the Deployment
Lines 147-161 Link Here
147
		DdeUtil.serializeDescriptorRoot(_ddRoot, fileURI);
144
		DdeUtil.serializeDescriptorRoot(_ddRoot, fileURI);
148
	}
145
	}
149
	
146
	
150
	public void removeArtifacts() 
151
	{
152
		for(int i=0;i<_mrtPreProcessors.size();i++)
153
		{
154
			MrtPreProcessor mrtPreProcessor = (MrtPreProcessor) _mrtPreProcessors.get(i);
155
			mrtPreProcessor.removeArtifacts();
156
		}
157
	}
158
159
	/**
147
	/**
160
	 * Inspects the given manageable resource type for servicegroup/relationship kind of resource type and update the given
148
	 * Inspects the given manageable resource type for servicegroup/relationship kind of resource type and update the given
161
	 * merged RMD document for it by having the rules/relationships in it. 
149
	 * merged RMD document for it by having the rules/relationships in it. 
(-)src/org/eclipse/tptp/wsdm/tooling/editor/mrt/servicegroup/dialog/internal/ServiceGroupPropertyDialog.java (+2 lines)
Lines 208-216 Link Here
208
		for(int i =0;i<categoryArray.length;i++)
208
		for(int i =0;i<categoryArray.length;i++)
209
		{
209
		{
210
			Category category = (Category) categoryArray[i];
210
			Category category = (Category) categoryArray[i];
211
			category.removeUnExposedCapabilities();
211
			CapabilityInfo[] capabilityInfoArray = category.getCapabilitiesInfo();
212
			CapabilityInfo[] capabilityInfoArray = category.getCapabilitiesInfo();
212
			for(int j =0;j<capabilityInfoArray.length;j++)
213
			for(int j =0;j<capabilityInfoArray.length;j++)
213
			{
214
			{
215
				
214
				Capability cap = (Capability) capabilityInfoArray[j].getCapability();
216
				Capability cap = (Capability) capabilityInfoArray[j].getCapability();
215
				if(_isEdit && cap.getProperties().size() >0)
217
				if(_isEdit && cap.getProperties().size() >0)
216
				editCapabilityList.add(cap);
218
				editCapabilityList.add(cap);

Return to bug 173433