Java Code Examples for org.eclipse.emf.ecore.util.FeatureMap#get()

The following examples show how to use org.eclipse.emf.ecore.util.FeatureMap#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EMFExtensionUtil.java    From fixflow with Apache License 2.0 6 votes vote down vote up
/**
 * 获取数据变量
 * @param baseElement
 * @return
 */
@SuppressWarnings("unchecked")
public static List<DataVariable> getDataVariables(BaseElement baseElement) {

	
	if (baseElement.getExtensionValues().size() > 0) {
		for (ExtensionAttributeValue extensionAttributeValue : baseElement.getExtensionValues()) {
			FeatureMap extensionElements = extensionAttributeValue.getValue();
			Object objectElement = extensionElements.get(FixFlowPackage.Literals.DOCUMENT_ROOT__DATA_VARIABLE, true);
			if (objectElement != null) {

				return (List<DataVariable>) objectElement;
			

			}
		}
	}

	return null;
}
 
Example 2
Source File: BPMNToProc.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected String getAssignmentValue(final TExpression to) {
    if (to != null) {
        final FeatureMap mixed = to.getMixed();
        if (mixed != null && !mixed.isEmpty()) {
            final Entry entry = mixed.get(0);
            if (entry != null) {
                return (String) entry.getValue();
            }
        }
    }
    return "";
}
 
Example 3
Source File: BPMNToProc.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private String retrieveDefaultValueContent(final TExpression fromExpression) {
    String defaultValueContent = "";
    final FeatureMap fromMixed = fromExpression
            .getMixed();
    if (fromMixed != null && !fromMixed.isEmpty()) {
        final Entry fromEntry = fromMixed.get(0);
        if (fromEntry != null) {
            defaultValueContent = (String) fromEntry
                    .getValue();
        }
    }
    return defaultValueContent;
}
 
Example 4
Source File: ServerHostImpl.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
private Hive createHive ( final String ref, final FeatureMap featureMap ) throws Exception
{
    final Entry first = featureMap.get ( 0 );
    final BundleContextHiveFactory factory = new BundleContextHiveFactory ( HivesPlugin.getDefault ().getBundle ().getBundleContext () );
    return factory.createHive ( ref, (EObject)first.getValue () );
}
 
Example 5
Source File: EMFUtil.java    From fixflow with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public static <T> List<T> getExtensionElementList( Class<T> t ,BaseElement baseElement,EReference eReference){
	
	
	if (baseElement.getExtensionValues().size() > 0) {
		for (ExtensionAttributeValue extensionAttributeValue : baseElement.getExtensionValues()) {
			FeatureMap extensionElements = extensionAttributeValue.getValue();
			Object objectElement = extensionElements.get(eReference, true);
			if (objectElement != null) {

				List<T> tObjList = (List<T>) objectElement;
				return tObjList;
			

			}
		}
	}
	
	
	return (List<T>)null;
}
 
Example 6
Source File: BPMNToProc.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
protected void createBonitaData(final TFlowElement flowElement,
        final boolean isMultiple, final QName itemDef, final boolean isTransient)
        throws ProcBuilderException {
    final TItemDefinition itemDefinition = getItemDefinition(itemDef);
    String id = null;
    DataType dataType = null;
    if (itemDefinition != null) {
        if (itemDefinition.getId() != null) {
            id = flowElement.getId();
        } else {
            id = "data" + dataNameByItemDefinition.size();
        }
        dataType = getDataType(itemDefinition);
    } else {
        if (flowElement.getId() != null) {
            id = flowElement.getId();
        } else {
            id = "data" + dataNameByItemDefinition.size();
        }
        dataType = DataType.STRING;
    }

    final String name = createBonitaDataName(flowElement, id);
    String defaultValueContent = "";
    String defaultValueReturnType = "";
    String defaultValueInterpreter = "";
    if (flowElement instanceof TActivity) {
        for (final TDataInputAssociation dataInputAssociation : ((TActivity) flowElement).getDataInputAssociation()) {
            for (final TAssignment assignment : dataInputAssociation.getAssignment()) {
                final TExpression to = assignment.getTo();
                if (to != null) {
                    final FeatureMap toMixed = to.getMixed();
                    if (toMixed != null && !toMixed.isEmpty()) {
                        final Entry entry = toMixed.get(0);
                        if (entry != null) {
                            final String entryValue = (String) entry.getValue();// .replaceFirst(Matcher.quoteReplacement("getDataInput('"),
                            // "").replace(Matcher.quoteReplacement("\')"),
                            // "");
                            final TDataInput dataInput = getDataInputById((TActivity) flowElement, entryValue);
                            if (dataInput != null) {
                                final TProperty property = getPropertyByItemSubjectRef((TActivity) flowElement,
                                        dataInput.getItemSubjectRef());
                                if (property != null) {
                                    final TExpression fromExpression = assignment.getFrom();
                                    defaultValueContent = retrieveDefaultValueContent(fromExpression);

                                    if (fromExpression instanceof TFormalExpression) {
                                        final TFormalExpression fromFormalExpression = (TFormalExpression) fromExpression;
                                        defaultValueInterpreter = retrieveDefaultValueInterpreter(fromFormalExpression);
                                        final QName evaluatesToTypeRef = fromFormalExpression.getEvaluatesToTypeRef();
                                        if (evaluatesToTypeRef != null) {
                                            defaultValueReturnType = evaluatesToTypeRef.getLocalPart();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    if (IProcBuilder.DataType.XML.equals(dataType)) {
        builder.addXMLData(id, name, defaultValueContent,
                defaultValueReturnType, defaultValueInterpreter,
                itemDefinition.getStructureRef().getLocalPart(),
                itemDefinition.getStructureRef().getNamespaceURI(),
                isMultiple, isTransient, ExpressionConstants.XPATH_TYPE);
    } else if (IProcBuilder.DataType.JAVA.equals(dataType)) {
        builder.addJavaData(id, name, defaultValueContent,
                defaultValueReturnType, defaultValueInterpreter,
                itemDefinition.getStructureRef().getLocalPart(),
                isMultiple, isTransient, ExpressionConstants.JAVA_TYPE);
    } else {
        String defaultValueExpressionType = null;
        if ("http://groovy.codehaus.org/".equals(defaultValueInterpreter)) {
            defaultValueExpressionType = ExpressionConstants.SCRIPT_TYPE;
        } else if ("http://www.w3.org/1999/XPath".equals(defaultValueInterpreter)) {
            defaultValueExpressionType = ExpressionConstants.CONSTANT_TYPE;
        }
        builder.addData(id, name, defaultValueContent,
                defaultValueReturnType, defaultValueInterpreter,
                isMultiple, isTransient, dataType,
                defaultValueExpressionType);// TODO how to define the real
        // type of the expression??
    }
    if (itemDefinition != null) {
        dataNameByItemDefinition.put(itemDefinition.getId(), name);
    }
}
 
Example 7
Source File: EMFUtil.java    From fixflow with Apache License 2.0 2 votes vote down vote up
@SuppressWarnings("unchecked")
public static <T> T getExtensionElementOne(Class<T> t ,BaseElement baseElement,EReference eReference){

	
	if(baseElement==null){
		return null;
	}
	
	if (baseElement.getExtensionValues().size() > 0) {
		for (ExtensionAttributeValue extensionAttributeValue : baseElement.getExtensionValues()) {
			FeatureMap extensionElements = extensionAttributeValue.getValue();
			
			Object objectElement = extensionElements.get(eReference, true);
			if (objectElement != null) {

				
				if(objectElement instanceof List){
					List<T> tObjList = (List<T>) objectElement;
					if(tObjList.size()>0){
						return tObjList.get(0);
					}
					
				}else{
					return (T)objectElement;
				}
				
			

			}
			/*
			for (Entry entry : extensionElements) {
				if (t.isInstance(entry.getValue())) {
					
					T objectT=(T)entry.getValue();
					return objectT;
				}

			}
			*/
			
		}
	}
	
	
	
	
	
	return (T)null;
}