blob: 60d07cd891b72d8ca3bd30f0ff40cf2c245471cc [file] [log] [blame]
/**
*
* Copyright (c) 2011, 2016 - 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
*/
package org.eclipse.osbp.ui.api.metadata;
import java.net.URL;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.osbp.dsl.xtext.types.bundles.BundleSpaceTypeProvider;
import org.eclipse.osbp.ui.api.useraccess.IUserAccessService;
import org.eclipse.xtext.common.types.JvmTypeReference;
import org.eclipse.xtext.resource.IEObjectDescription;
import org.eclipse.xtext.util.Pair;
/**
* The Interface IDSLMetadataService.
*/
public interface IDSLMetadataService {
/**
* The Enum DSLLiterals avoids dependencies to the concrete DSL
* implementations.
*/
enum DSLLiterals {
/** The perspective literal placeholder. */
PERSPECTIVES
}
public static final String DASHBOARD = "osbee.Dashboard";
public static final class ThrowableMessages {
private ThrowableMessages() {
}
public static final String NAMING_LOGIC_NOT_REGISTERD = "No registered naming logic for ";
}
/**
* Gets dsl grammar elements identified by a literal enum.
*
* @param literal
* the literal
* @return iterator for dsl grammar elements
*/
@SuppressWarnings("rawtypes")
List<Pair> getDslGrammarElementNames(IDSLMetadataService.DSLLiterals literal);
/**
* Returns the EObject to be casted to the requested model for the given
* model id and EClass.
*
* @param id
* the id
* @param eclass
* the eclass
* @return the metadata
*/
EObject getMetadata(String id, EClass eclass);
/**
* Returns the ecview id for the given Dialog.
* @param dialog
* @return
*/
String getECViewId(EObject dialog);
/**
* Gets the all metadata descriptions.
*
* @param eClass
* the e class
* @return the all descriptions
*/
Iterable<IEObjectDescription> getAllDescriptions(EClass eClass);
/**
* Returns the fully qualified name for the given eObject. If the model is
* based on Xtext, then the returned fqn should be used from the
* EObjectDescription.
*
* @param eObject
* the EObject
* @return the fully qualified name
*/
String getFullyQualifiedName(EObject eObject);
/**
* Returns the class name for the given eObject. Kind specifies which type
* of class should be returned. The types depend on their xtext inferrer.
* There may be kind "ui", "translator", "service",...<br>
* If you have no idea what should be returned, just leave the kind
* <code>null</code>.
*
* @param eObject
* the EObject
* @param kind
* the kind of requested class type. Depends on the underlying
* model. Leave null for default.
* @return the class name
*/
String getClassName(EObject eObject, String kind);
/**
* Returns all the classpath URI for a given extension.
*
* @param className
* the class name
* @param extension
* the extension
* @return the class uri
*/
String getClassURI(String className, String extension);
/**
* Returns the class URI for the given eObject and kind. For kind see
* {@link #getClassName(EObject, String)}.
*
* @param eObject
* the eObject
* @param kind
* the kind
* @return the class URI
*/
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
* @param extension the extension
* @return the class
*/
Class<?> getClass(EObject eObject, String extension);
/**
* Gets a class instance for the given eObject and extension.
*
* @param eObject the e object
* @param extension the extension
* @return the class instance
*/
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
* @param dslExtension the dsl extension e.g. report
* @return the resource URL
*/
URL getResourceURL(String resourceName, String dslExtension);
/**
* Resolves the given proxy using the internal resource set.
*
* @param proxy
* the proxy instance
* @return resolved EObject
*/
EObject resolve(EObject proxy);
/**
* Returns all resolved EObjects provided by
* {@link #getAllDescriptions(EClass)}.
*
* @param eClass
* the e class
* @return the all EObjects
*/
Iterable<EObject> getAll(EClass eClass);
/**
* Translates a fully qualified key for the given locale.
*
* @param locale
* the locale
* @param key
* the key
* @return the string
*/
String translate(String locale, String key);
/**
* Gets all translations.
*
* @return the translations for all languages
*/
Map<String, Properties> getTranslations();
/**
* Gets the bundle space type provider from MetadataBuilderService.
*
* @return the type provider
*/
BundleSpaceTypeProvider getTypeProvider();
/**
* 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 type
* the type
* @return all applicable type names
*/
Map<String, Object> getAllSubtypes(String localeTag, Class<?> type);
/**
* Creates an instance of the given qualified type.
*
* @param typeName
* the type name
* @return the class
* @throws ClassNotFoundException
* the class not found exception
*/
Class<?> createType(String typeName) throws ClassNotFoundException;
/**
* Execute a unit of work via {@link IMetadataBuilderService}.
*
* @param <T> the generic type
* @param state the state
* @param unitOfWork the unit of work
*/
<T> void execute(T state, Object unitOfWork);
/**
* Gets the root entity class of a datamart.
*
* @param canonicalName the canonical name of the datamart
* @return the entity root class
*/
Class<?> getDatamartRootClass(String canonicalName);
String getDatamartRootClassIdentifierName(String canonicalName);
/**
* Checks if is osbee.
*
* @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 getEntityClassLoader(String resourceName);
/**
* Gets the class loader of a given full qualified class.
*
* @param className
* @param extension
* @return
*/
ClassLoader getClassLoader(String className, String extension);
/**
* 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);
/**
* Checks if the given perspective elements are authorized.
*
* @param fqn the fully qualified model element id
* @param userAccessService the user access service
* @return true, if perspective is authorized
*/
boolean isPerspectiveAuthorized(String fqn, IUserAccessService userAccessService);
/**
* Checks if a perspective element is authorized.
*
* @param modelElement the model element
* @param userAccessService the user access service
* @return true, if is perspective element authorized
*/
boolean isPerspectiveElementAuthorized(EObject modelElement, IUserAccessService userAccessService);
/**
* Checks if a menu category is authorized.
*
* @param fqn the fully qualified model element id
* @param userAccessService the user access service
* @return true, if menu category is authorized
*/
boolean isMenuCategoryAuthorized(String fqn, IUserAccessService userAccessService);
/**
* Checks if menu tree is authorized.
*
* @param fqn the fully qualified model element id
* @param userAccessService the user access service
* @return true, if menu tree is authorized
*/
boolean isMenuTreeAuthorized(String fqn, IUserAccessService userAccessService);
/**
* Checks an xtext typeReference for a given supertype.
*
* @param typeReference the type reference
* @param clz the clz
* @return true, if successful
*/
boolean hasSupertype(JvmTypeReference typeReference, Class<?> clz);
/**
* Gets the DTOs using a given full qualified stateClass.
*
* @param stateClassName the state class name
* @return the DTOs for stateClass
*/
Set<String> getDTOsForStateClass(String stateClassName);
}