catch up with branch daily

Signed-off-by: Ralf Mollik <ramollik@compex-commerce.com>
diff --git a/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/contextfunction/IViewEmbeddedProvider.java b/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/contextfunction/IViewEmbeddedProvider.java
index 12aaf0f..44724b8 100644
--- a/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/contextfunction/IViewEmbeddedProvider.java
+++ b/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/contextfunction/IViewEmbeddedProvider.java
@@ -19,4 +19,6 @@
 public interface IViewEmbeddedProvider {
 	void createView(final VerticalLayout parent);
 	void createComponents();
+	void setEnableManualInput(boolean manualInput);
+	void setInput(Object dto);
 }
diff --git a/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/customfields/ICustomComponentFocusable.java b/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/customfields/ICustomComponentFocusable.java
new file mode 100644
index 0000000..84ee128
--- /dev/null
+++ b/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/customfields/ICustomComponentFocusable.java
@@ -0,0 +1,26 @@
+/**
+ *                                                                            
+ * Copyright (c) 2011, 2018 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
+ *                                                                            
+ * All rights reserved. This program and the accompanying materials           
+ * are made available under the terms of the Eclipse Public License 2.0        
+ * which accompanies this distribution, and is available at                  
+ * https://www.eclipse.org/legal/epl-2.0/                                 
+ *                                 
+ * SPDX-License-Identifier: EPL-2.0                                 
+ *                                                                            
+ * Contributors:   
+ * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation 
+ * Ornel Franck Wora Yeno (Compex Systemhaus GmbH) - ongoing development 
+ */
+
+package org.eclipse.osbp.ui.api.customfields;
+
+import com.vaadin.event.FieldEvents;
+
+public interface ICustomComponentFocusable extends FieldEvents.BlurNotifier, FieldEvents.FocusNotifier {
+
+	public boolean isFirstFocusable(Object element);
+	public boolean isLastFocusable(Object element);
+	
+}
diff --git a/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/datamart/DatamartFilter.java b/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/datamart/DatamartFilter.java
index 0520fca..36ff1cc 100644
--- a/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/datamart/DatamartFilter.java
+++ b/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/datamart/DatamartFilter.java
@@ -15,20 +15,16 @@
  */
 package org.eclipse.osbp.ui.api.datamart;
 
-import java.text.DateFormat;
-import java.util.AbstractMap.SimpleEntry;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.stream.Collectors;
 
-import org.eclipse.e4.core.contexts.IEclipseContext;
 import org.eclipse.osbp.runtime.common.event.EventDispatcherEvent.EventDispatcherDataTag;
+import org.eclipse.osbp.runtime.common.event.IDualData;
 import org.eclipse.osbp.ui.api.metadata.IDSLMetadataService;
 import org.eclipse.osbp.ui.api.user.IUser;
-import org.eclipse.osbp.runtime.common.event.IDualData;
 
 /**
  * The Class DatamartFilter.
@@ -207,9 +203,12 @@
     }
     
 
-    /** The name. */
+    /** The name. Could be the aliased name if it exists.*/
     private String name;
     
+    /** The short name. No aliased name even if it exists.*/
+    private String shortName;
+    
     /** The type. */
     private FilterType type;
     
@@ -250,10 +249,24 @@
      * @param sql the sql
      */
     public DatamartFilter(IDSLMetadataService dslMetadataService, IUser user, FilterType type, String name, String sql, boolean optional) {
+    	this( dslMetadataService, user, type, name, "", sql, optional);
+    }
+    
+	/**
+	 * Instantiates a new datamart filter for non date data typed attributes.
+	 *
+	 * @param type the type
+	 * @param dateFormatMap
+	 * @param name the name
+	 * @param shortName the short name
+	 * @param sql the sql
+	 */
+	public DatamartFilter(IDSLMetadataService dslMetadataService, IUser user, FilterType type, String name, String shortName, String sql, boolean optional) {
     	this.dslMetadataService = dslMetadataService;
     	this.user = user;
     	this.type = type;
     	this.name = name;
+    	this.shortName = shortName;
     	this.sql = sql;
     	this.setOptional(optional);
     	data = new ArrayList<>();
@@ -266,13 +279,27 @@
      * @param type the type
      * @param dateFormatMap
      * @param name the name
+     * @param shortName the short name
      * @param sql the sql
      */
     public DatamartFilter(IDSLMetadataService dslMetadataService, IUser user, FilterType type, Map<String, String> dateFormatMap, String name, String sql, boolean optional) {
+    	this(dslMetadataService, user, type, dateFormatMap, name, "", sql, optional);
+    }
+    
+	/**
+	 * Instantiates a new datamart filter for date data typed attributes.
+	 *
+	 * @param type the type
+	 * @param dateFormatMap
+	 * @param name the name
+	 * @param sql the sql
+	 */
+	public DatamartFilter(IDSLMetadataService dslMetadataService, IUser user, FilterType type, Map<String, String> dateFormatMap, String name, String shortName, String sql, boolean optional) {
     	this.dslMetadataService = dslMetadataService;
     	this.user = user;
     	this.type = type;
     	this.name = name;
+    	this.shortName = shortName;
     	DateTimeFormat format = null;
     	DateResolution resolution = null;
     	if (dateFormatMap != null) {
@@ -303,6 +330,33 @@
 	}
 	
 	/**
+	 * Sets the name.
+	 *
+	 * @param name the new name
+	 */
+	public void setName(String name) {
+		this.name = name;
+	}
+	
+	/**
+	 * Gets the short name.
+	 *
+	 * @return the short name
+	 */
+	public String getShortName() {
+		return shortName;
+	}
+	
+	/**
+	 * Sets the short name.
+	 *
+	 * @param shortName the new short name
+	 */
+	public void setShortName(String shortName) {
+		this.shortName = shortName;
+	}
+	
+	/**
 	 * Gets the decorated name.
 	 *
 	 * @return the decorated name
@@ -322,15 +376,6 @@
 	}
 	
 	/**
-	 * Sets the name.
-	 *
-	 * @param name the new name
-	 */
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	/**
 	 * Gets the type.
 	 *
 	 * @return the type
diff --git a/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/functionlibrary/IFunctionLibraryService.java b/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/functionlibrary/IFunctionLibraryService.java
index 699831e..f689493 100644
--- a/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/functionlibrary/IFunctionLibraryService.java
+++ b/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/functionlibrary/IFunctionLibraryService.java
@@ -15,6 +15,7 @@
  */
  package org.eclipse.osbp.ui.api.functionlibrary;
 
+import java.lang.reflect.Method;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
@@ -28,6 +29,8 @@
  */
 public interface IFunctionLibraryService {
 
+	public Class<IFunctionLibraryGroup> getFunctionLibraryClass(String className);
+	
 	public Object invoke(String className, String methodName,
 			Object fieldValue, Locale locale, Object... params);
 
@@ -55,5 +58,5 @@
 	
 	public Set<IStatus> validation(String className, Object clazz, Map<String, Object> properties);
 	
-	public boolean initialization(String className, String methodName, Object clazz, Map<String, Object> properties);
+	public Method getMethod(Class<?> clazz, String methodName);
 }
diff --git a/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/metadata/IDSLMetadataService.java b/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/metadata/IDSLMetadataService.java
index 47afb21..ecf7165 100644
--- a/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/metadata/IDSLMetadataService.java
+++ b/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/metadata/IDSLMetadataService.java
@@ -135,6 +135,14 @@
 	String getClassURI(EObject eObject, String kind);
 
 	/**
+	 * Gets the class the given full qualified name and extension.
+	 *
+	 * @param fqn the fqn
+	 * @param extension the extension
+	 * @return the class
+	 */
+	Class<?> getClass(String fqn, String extension);
+	/**
 	 * Gets the class for the given eObject and extension.
 	 *
 	 * @param eObject the e object
@@ -152,6 +160,14 @@
 	Object getClassInstance(EObject eObject, String extension);
 	
 	/**
+	 * Gets the class instance for the given class and extension.
+	 *
+	 * @param clz the clz
+	 * @param extension the extension
+	 * @return the class instance
+	 */
+	Object getClassInstance(Class<?> clz, String extension);
+	/**
 	 * Gets a resource URL from the bundle of the given extension.
 	 *
 	 * @param resourceName the resource name
@@ -205,17 +221,16 @@
 	BundleSpaceTypeProvider getTypeProvider();
 
 	/**
-	 * Returns a set with all sub types of the given type. The key holds the
-	 * localized simple name if localeTag is != null The value holds the
-	 * qualified name of the type
+	 * Returns a set with all sub-types of the given super-type. The key holds the
+	 * localized simple name if localeTag is != null The value holds the type
 	 * 
 	 * @param localeTag
 	 *            the locale tag
-	 * @param typeName
-	 *            the type name
+	 * @param type
+	 *            the type
 	 * @return all applicable type names
 	 */
-	Map<String, String> getAllTypeNames(String localeTag, String typeName);
+	Map<String, Object> getAllSubtypes(String localeTag, Class<?> type);
 
 	/**
 	 * Creates an instance of the given qualified type.
@@ -252,4 +267,27 @@
 	 * @return true, if we loaded osbee related bundles
 	 */
 	boolean isOsbee();
+	
+	/**
+	 * Gets the class loader of a given full qualified entity resource.
+	 *
+	 * @param resourceName the resource name
+	 * @return the class loader
+	 */
+	ClassLoader getClassLoader(String resourceName);
+	
+	/**
+	 * Gets the persistence unit info for a given name.
+	 *
+	 * @param persistenceUnitName the persistence unit name
+	 * @return the persistence unit info
+	 */
+	Object getPersistenceUnitInfo(String persistenceUnitName);
+	
+	/**
+	 * unload a model resource.
+	 *
+	 * @param extension the extension
+	 */
+	void unloadModel(String extension);
 }
diff --git a/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/perspective/IPerspectiveProvider.java b/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/perspective/IPerspectiveProvider.java
index e19b2f8..ad5161e 100644
--- a/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/perspective/IPerspectiveProvider.java
+++ b/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/perspective/IPerspectiveProvider.java
@@ -31,6 +31,7 @@
 		public static final String SEARCH = "search";
 		public static final String DATAINTERCHANGE = "data";
 		public static final String SIGNAL = "signal";
+		public static final String FUNCTIONLIBRARY = "functionlibrary";
 	}
 	
 	public static final class FilterConstants {
@@ -106,7 +107,11 @@
 		/**
 		 * Name of the key corresponding to the list of accepted senders. 
 		 */
-		public static final String ACCEPTED_SENDERS = "accepted_senders"; 
+		public static final String ACCEPTED_SENDERS = "accepted_senders";
+		/**
+		 * key for transient data of partStacks to synchronize with other partStack
+		 */
+		public static final String SYNCHRONIZE_WITH = "synchronize_with"; 
 	}
 
 	void openPerspective(String perspectiveId);
diff --git a/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/themes/EnumCssClass.java b/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/themes/EnumCssClass.java
index fa50e8e..21b0554 100644
--- a/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/themes/EnumCssClass.java
+++ b/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/themes/EnumCssClass.java
@@ -50,7 +50,8 @@
 	MPARTTOOLBAR,
 	TOOLBAR_STATE,
 	TOOLBAR_BUTTON,
-	TOOLBAR_STATE_CONTAINER;
+	TOOLBAR_STATE_CONTAINER,
+	IMAGE_UPLOAD;
 
 	public String styleName() {
 		return toString();
diff --git a/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/useraccess/AbstractAuthorization.java b/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/useraccess/AbstractAuthorization.java
index eafdb5d..4b6e484 100644
--- a/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/useraccess/AbstractAuthorization.java
+++ b/org.eclipse.osbp.ui.api/src/org/eclipse/osbp/ui/api/useraccess/AbstractAuthorization.java
@@ -35,6 +35,9 @@
 	/** The role permissions. */
 	private HashMap<String, List<Set<Permission>>> rolePermissions = new HashMap<>();
 
+	/** the fast lookup map */
+	private HashMap<String, Action> fastPermissions = new HashMap<>();
+
 	/**
 	 * Adds the role permissions.
 	 *
@@ -42,7 +45,14 @@
 	 * @param permissions the permissions
 	 */
 	public void addRolePermissions(String roleName, List<Set<Permission>> permissions) {
+		String key;
 		rolePermissions.put(roleName, permissions);
+		for(Set<Permission> permissionSet : permissions) {
+			for(Permission permission:permissionSet) {
+				key = String.format("%s%s%s%s", roleName, permission.group, permission.clazz, permission.attribute);
+				fastPermissions.put(key,  permission.action);
+			}
+		}
 	}
 
 	/**
@@ -75,38 +85,70 @@
 	}
 
 	public boolean isApplicableGrant(Group group, Action action, String descriptor) {
-		LOGGER.debug("isApplicableGrant group:{} action:{} descriptor:{}", group, action, descriptor);
 		for(String roleName : getRoles()) {
-			for(Set<Permission> permissionSet : getAuthorizationGroups().get(roleName)) {
-				for(Permission permission:permissionSet) {
-					LOGGER.trace("role:{} permission:{}", roleName, permission);
-					if(permission.clazz.equals(descriptor) && permission.group == group && permission.action.getWeight() >= action.getWeight()) {
-						LOGGER.debug("grant result {}", true);
-						return true;
-					}
+			String key = String.format("%s%s%snull", roleName, group, descriptor);
+			if(fastPermissions.containsKey(key)) {
+				Action a = fastPermissions.get(key);
+				if(a.getWeight() >= action.getWeight()) {
+					return true;
 				}
 			}
 		}
-		LOGGER.debug("grant result {}", false);
 		return false;
 	}
 
+//	public boolean isApplicableGrant(Group group, Action action, String descriptor) {
+//		LOGGER.debug("isApplicableGrant group:{} action:{} descriptor:{}", group, action, descriptor);
+//		for(String roleName : getRoles()) {
+//			for(Set<Permission> permissionSet : getAuthorizationGroups().get(roleName)) {
+//				for(Permission permission:permissionSet) {
+//					LOGGER.trace("role:{} permission:{}", roleName, permission);
+//					if(permission.clazz.equals(descriptor) && permission.group == group && permission.action.getWeight() >= action.getWeight()) {
+//						LOGGER.debug("grant result {}", true);
+//						return true;
+//					}
+//				}
+//			}
+//		}
+//		LOGGER.debug("grant result {}", false);
+//		return false;
+//	}
+
 	public boolean isApplicableVeto(Group group, Action action, String descriptor, String property) {
-		LOGGER.debug("isApplicableVeto group:{} action:{} descriptor:{} property:{}", group, action, descriptor, property);
 		for(String roleName : getRoles()) {
-			for(Set<Permission> permissionSet : getAuthorizationGroups().get(roleName)) {
-				for(Permission permission:permissionSet) {
-					LOGGER.trace("role:{} permission:{}", roleName, permission);
-					if(permission.clazz.equals(descriptor) && permission.attribute != null && permission.attribute.equals(property) && permission.group == group && permission.action.getWeight() < action.getWeight()) {
-						LOGGER.debug("veto result {}", false);
-						return false;
-					}
+			String key = String.format("%s%s%s%s", roleName, group, descriptor, property);
+			if(fastPermissions.containsKey(key)) {
+				Action a = fastPermissions.get(key);
+				if (a.getWeight() < action.getWeight()) {
+					return false;
+				} else {
+					return true;
 				}
 			}
 		}
-		LOGGER.debug("veto result {}", true);
-		return true;
+		return false;
 	}
+//	public boolean isApplicableVeto(Group group, Action action, String descriptor, String property) {
+//		LOGGER.debug("isApplicableVeto group:{} action:{} descriptor:{} property:{}", group, action, descriptor, property);
+//		for(String roleName : getRoles()) {
+//			for(Set<Permission> permissionSet : getAuthorizationGroups().get(roleName)) {
+//				for(Permission permission:permissionSet) {
+//					LOGGER.trace("role:{} permission:{}", roleName, permission);
+//					if(permission.clazz.equals(descriptor) && permission.attribute != null && permission.attribute.equals(property) && permission.group == group) {
+//						if(permission.action.getWeight() < action.getWeight()) {
+//							LOGGER.debug("veto result {}", false);
+//							return false;
+//						} else {
+//							LOGGER.debug("veto result {}", true);
+//							return true;
+//						}
+//					}
+//				}
+//			}
+//		}
+//		LOGGER.debug("veto result {}", false);
+//		return true;
+//	}
 
 	/**
 	 * Granted.