Skip to main content
summaryrefslogtreecommitdiffstats
blob: 205a67aa2abb8afc5a5e6e60a516fb730c6ef9f7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*******************************************************************************
 * Copyright (c) 2003, 2004 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 * IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jst.j2ee.internal.jca.operations;


import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.jst.j2ee.application.internal.operations.DefaultModuleProjectCreationOperation;
import org.eclipse.jst.j2ee.common.XMLResource;
import org.eclipse.jst.j2ee.internal.J2EEConstants;
import org.eclipse.jst.j2ee.internal.J2EEEditModel;
import org.eclipse.jst.j2ee.jca.Connector;
import org.eclipse.jst.j2ee.jca.JcaPackage;
import org.eclipse.wst.common.internal.emfworkbench.EMFWorkbenchContext;
import org.eclipse.wst.common.internal.emfworkbench.integration.EditModel;

/**
 * Creates an edit model for the Connector project.
 * @deprecated
 * Use
 * <p>
 * 	ConnectorArtifactEdit
 * </p>
 */
public class ConnectorEditModel extends J2EEEditModel {
	/**
	 * @param editModelID
	 * @param context
	 * @param readOnly
	 */
	public ConnectorEditModel(String editModelID, EMFWorkbenchContext context, boolean readOnly) {
		super(editModelID, context, readOnly);
	}

	/**
	 * @param editModelID
	 * @param context
	 * @param readOnly
	 * @param knownResourceURIs
	 * @param shouldAccessUnkownURIsAsReadOnly
	 */
	public ConnectorEditModel(String editModelID, EMFWorkbenchContext context, boolean readOnly, boolean accessUnkownResourcesAsReadOnly) {
		super(editModelID, context, readOnly, accessUnkownResourcesAsReadOnly);
	}

	public ConnectorNatureRuntime getConnectorNature() {
		return ConnectorNatureRuntime.getRuntime(getProject());
	}

	/**
	 * Return the root element of the DD which is the Connector element, from ra.xml.
	 * 
	 * @return Connector
	 */
	public Connector getConnector() {
		Resource dd = this.getConnectorXmiResource();
		if (dd != null) {
			Object rootObject = EditModel.getRoot(dd);
			if (rootObject instanceof Connector) {
				return (Connector) rootObject;
			}
		}
		return null;
	}

	/**
	 * Returns the respected resource based on an archive constant.
	 * 
	 * @return Resource
	 * @throws Exception
	 */
	public Resource getConnectorXmiResource() {
		return getResource(J2EEConstants.RAR_DD_URI_OBJ);
	} // getConnectorXmiResource

	/**
	 * Creates an connector XMI resource
	 * 
	 * @return Resource
	 */
	public Resource makeConnectorXmiResource() {
		return createResource(J2EEConstants.RAR_DD_URI_OBJ);
	} // makeConnectorXmiResource

	/**
	 * Creates the deployment descriptor.
	 * 
	 * @return Resource
	 */
	public Resource makeDeploymentDescriptorWithRoot() {
		org.eclipse.jst.j2ee.common.XMLResource res = (org.eclipse.jst.j2ee.common.XMLResource) makeConnectorXmiResource();
		Connector connector = JcaPackage.eINSTANCE.getJcaFactory().createConnector();
		res.getContents().add(connector);
		res.setID(connector, J2EEConstants.CONNECTOR_ID);
		res.setModuleVersionID(getConnectorNature().getModuleVersion());
		connector.setDisplayName(getProject().getName());
		return res;
	} // makeDeploymentDescriptorWithRoot

	public XMLResource getDeploymentDescriptorResource() {
		return (XMLResource) getConnectorXmiResource();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jst.j2ee.internal.internal.workbench.J2EEEditModel#getRootObject()
	 */
	public Object getRootObject() {
		return getConnector();
	}

	public String getDevelopmentAcivityID() {
		return DefaultModuleProjectCreationOperation.ENTERPRISE_JAVA;
	}

}

Back to the top