blob: bce064416237df3d3d57d2d8b858ff711949d595 [file] [log] [blame]
/***********************************************************************************************************************
* Copyright (c) 2010 Attensity Europe GmbH.
* 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
**********************************************************************************************************************/
package org.eclipse.smila.processing.designer.model.processor.impl;
import java.util.List;
import org.eclipse.bpel.model.impl.ExtensionActivityImpl;
import org.eclipse.bpel.model.util.ReconciliationHelper;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.smila.processing.designer.model.processor.*;
import org.eclipse.smila.processing.designer.model.processor.util.DOMUtils;
import org.eclipse.smila.processing.designer.model.processor.util.ProcessorConstants;
import org.w3c.dom.Element;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Invoke Service</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.smila.processing.designer.model.processor.impl.InvokeServiceImpl#getService <em>Service</em>}</li>
* <li>{@link org.eclipse.smila.processing.designer.model.processor.impl.InvokeServiceImpl#getVariables <em>Variables</em>}</li>
* <li>{@link org.eclipse.smila.processing.designer.model.processor.impl.InvokeServiceImpl#getSetAnnotations <em>Set Annotations</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class InvokeServiceImpl extends ExtensionActivityImpl implements InvokeService
{
/**
* The cached value of the '{@link #getService() <em>Service</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getService()
* @generated
* @ordered
*/
protected Service service;
/**
* The cached value of the '{@link #getVariables() <em>Variables</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getVariables()
* @generated
* @ordered
*/
protected Variables variables;
/**
* The cached value of the '{@link #getSetAnnotations() <em>Set Annotations</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getSetAnnotations()
* @generated
* @ordered
*/
protected SetAnnotations setAnnotations;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @customized
*/
protected InvokeServiceImpl()
{
setService(ProcessorFactory.eINSTANCE.createService());
setVariables(ProcessorFactory.eINSTANCE.createVariables());
setSetAnnotations(ProcessorFactory.eINSTANCE.createSetAnnotations());
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass()
{
return ProcessorPackage.Literals.INVOKE_SERVICE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Service getService()
{
return service;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @customized
*/
public NotificationChain basicSetService(Service newService, NotificationChain msgs)
{
Service oldService = service;
service = newService;
if (!isReconciling)
{
ReconciliationHelper.replaceChild(this, oldService, newService);
}
if (eNotificationRequired())
{
ENotificationImpl notification =
new ENotificationImpl(this, Notification.SET, ProcessorPackage.INVOKE_SERVICE__SERVICE, oldService,
newService);
if (msgs == null)
{
msgs = notification;
}
else
{
msgs.add(notification);
}
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @customized
*/
public void setService(Service newService)
{
if (newService != service)
{
NotificationChain msgs = null;
if (service != null)
{
msgs =
((InternalEObject) service).eInverseRemove(this, EOPPOSITE_FEATURE_BASE
- ProcessorPackage.INVOKE_SERVICE__SERVICE, null, msgs);
}
if (newService != null)
{
msgs =
((InternalEObject) newService).eInverseAdd(this, EOPPOSITE_FEATURE_BASE
- ProcessorPackage.INVOKE_SERVICE__SERVICE, null, msgs);
}
msgs = basicSetService(newService, msgs);
if (msgs != null)
{
msgs.dispatch();
}
}
else if (eNotificationRequired())
{
eNotify(new ENotificationImpl(this, Notification.SET, ProcessorPackage.INVOKE_SERVICE__SERVICE, newService,
newService));
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Variables getVariables()
{
return variables;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @customized
*/
public NotificationChain basicSetVariables(Variables newVariables, NotificationChain msgs)
{
Variables oldVariables = variables;
variables = newVariables;
if (!isReconciling)
{
ReconciliationHelper.replaceChild(this, oldVariables, newVariables);
}
if (eNotificationRequired())
{
ENotificationImpl notification =
new ENotificationImpl(this, Notification.SET, ProcessorPackage.INVOKE_SERVICE__VARIABLES, oldVariables,
newVariables);
if (msgs == null)
{
msgs = notification;
}
else
{
msgs.add(notification);
}
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @customized
*/
public void setVariables(Variables newVariables)
{
if (newVariables != variables)
{
NotificationChain msgs = null;
if (variables != null)
{
msgs =
((InternalEObject) variables).eInverseRemove(this, EOPPOSITE_FEATURE_BASE
- ProcessorPackage.INVOKE_SERVICE__VARIABLES, null, msgs);
}
if (newVariables != null)
{
msgs =
((InternalEObject) newVariables).eInverseAdd(this, EOPPOSITE_FEATURE_BASE
- ProcessorPackage.INVOKE_SERVICE__VARIABLES, null, msgs);
}
msgs = basicSetVariables(newVariables, msgs);
if (msgs != null)
{
msgs.dispatch();
}
}
else if (eNotificationRequired())
{
eNotify(new ENotificationImpl(this, Notification.SET, ProcessorPackage.INVOKE_SERVICE__VARIABLES, newVariables,
newVariables));
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public SetAnnotations getSetAnnotations()
{
return setAnnotations;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @customized
*/
public NotificationChain basicSetSetAnnotations(SetAnnotations newSetAnnotations, NotificationChain msgs)
{
SetAnnotations oldSetAnnotations = setAnnotations;
setAnnotations = newSetAnnotations;
if (!isReconciling)
{
ReconciliationHelper.replaceChild(this, oldSetAnnotations, newSetAnnotations);
}
if (eNotificationRequired())
{
ENotificationImpl notification =
new ENotificationImpl(this, Notification.SET, ProcessorPackage.INVOKE_SERVICE__SET_ANNOTATIONS,
oldSetAnnotations, newSetAnnotations);
if (msgs == null)
{
msgs = notification;
}
else
{
msgs.add(notification);
}
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @customized
*/
public void setSetAnnotations(SetAnnotations newSetAnnotations)
{
if (newSetAnnotations != setAnnotations)
{
NotificationChain msgs = null;
if (setAnnotations != null)
{
msgs =
((InternalEObject) setAnnotations).eInverseRemove(this, EOPPOSITE_FEATURE_BASE
- ProcessorPackage.INVOKE_SERVICE__SET_ANNOTATIONS, null, msgs);
}
if (newSetAnnotations != null)
{
msgs =
((InternalEObject) newSetAnnotations).eInverseAdd(this, EOPPOSITE_FEATURE_BASE
- ProcessorPackage.INVOKE_SERVICE__SET_ANNOTATIONS, null, msgs);
}
msgs = basicSetSetAnnotations(newSetAnnotations, msgs);
if (msgs != null)
{
msgs.dispatch();
}
}
else if (eNotificationRequired())
{
eNotify(new ENotificationImpl(this, Notification.SET, ProcessorPackage.INVOKE_SERVICE__SET_ANNOTATIONS,
newSetAnnotations, newSetAnnotations));
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
{
switch (featureID)
{
case ProcessorPackage.INVOKE_SERVICE__SERVICE :
return basicSetService(null, msgs);
case ProcessorPackage.INVOKE_SERVICE__VARIABLES :
return basicSetVariables(null, msgs);
case ProcessorPackage.INVOKE_SERVICE__SET_ANNOTATIONS :
return basicSetSetAnnotations(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType)
{
switch (featureID)
{
case ProcessorPackage.INVOKE_SERVICE__SERVICE :
return getService();
case ProcessorPackage.INVOKE_SERVICE__VARIABLES :
return getVariables();
case ProcessorPackage.INVOKE_SERVICE__SET_ANNOTATIONS :
return getSetAnnotations();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID)
{
switch (featureID)
{
case ProcessorPackage.INVOKE_SERVICE__SERVICE :
return service != null;
case ProcessorPackage.INVOKE_SERVICE__VARIABLES :
return variables != null;
case ProcessorPackage.INVOKE_SERVICE__SET_ANNOTATIONS :
return setAnnotations != null;
}
return super.eIsSet(featureID);
}
/**
* Adds HTML elements to all properties.
*
* If a XML file contains no elements for the properties, any modification
* of these properties wouldn't be reflected in the XML file.
*
* Called when one of the properties changes itself.
*
* @return true if this element has an element, false else
*/
public boolean fixContent()
{
if (isReconciling || ReconciliationHelper.isLoading(this) || getElement() == null)
{
return false;
}
boolean oldUpdatingDOM = isUpdatingDOM();
try
{
setUpdatingDOM(true);
List<Element> childElements =
DOMUtils.getChildElements(getElement(), ProcessorPackage.eNS_URI, ProcessorConstants.NODE_INVOKE_SERVICE);
Element parentElement;
if (childElements.size() == 0)
{
parentElement =
getElement().getOwnerDocument().createElementNS(ProcessorPackage.eNS_URI,
ProcessorConstants.NODE_INVOKE_SERVICE);
parentElement.setPrefix(ProcessorPackage.eNS_PREFIX);
DOMUtils.appendIndented(getElement(), parentElement);
}
else
{
parentElement = childElements.get(0);
}
if (getService().getElement() == null)
{
Element element =
getElement().getOwnerDocument().createElementNS(ProcessorPackage.eNS_URI,
ProcessorConstants.NODE_SERVICE);
element.setPrefix(ProcessorPackage.eNS_PREFIX);
DOMUtils.insertIndented(parentElement, element, DOMUtils.getNextElement(getElement().getFirstChild()));
getService().setElement(element);
}
if (getVariables().getElement() == null)
{
Element element =
getElement().getOwnerDocument().createElementNS(ProcessorPackage.eNS_URI,
ProcessorConstants.NODE_VARIABLES);
element.setPrefix(ProcessorPackage.eNS_PREFIX);
DOMUtils.insertIndented(parentElement, element,
DOMUtils.getNextElement(getService().getElement().getNextSibling()));
getVariables().setElement(element);
}
if (getSetAnnotations().getElement() == null)
{
Element element =
getElement().getOwnerDocument().createElementNS(ProcessorPackage.eNS_URI,
ProcessorConstants.NODE_SET_ANNOTATIONS);
element.setPrefix(ProcessorPackage.eNS_PREFIX);
DOMUtils.appendIndented(parentElement, element);
getSetAnnotations().setElement(element);
}
return true;
}
finally
{
setUpdatingDOM(oldUpdatingDOM);
}
}
} //InvokeServiceImpl