| package org.eclipse.osbp.dsl.entity.xtext; |
| |
| import java.util.Map; |
| |
| import org.apache.log4j.Logger; |
| import org.eclipse.emf.ecore.EObject; |
| import org.eclipse.osbp.dsl.semantic.entity.LEntity; |
| import org.eclipse.xtext.naming.QualifiedName; |
| import org.eclipse.xtext.resource.CompilerPhases; |
| import org.eclipse.xtext.resource.EObjectDescription; |
| import org.eclipse.xtext.resource.IEObjectDescription; |
| import org.eclipse.xtext.resource.impl.DefaultResourceDescriptionStrategy; |
| import org.eclipse.xtext.util.IAcceptor; |
| |
| import com.google.common.collect.Maps; |
| import com.google.inject.Inject; |
| import com.google.inject.Singleton; |
| |
| @Singleton |
| public class EntityResourceDescriptionStrategy extends DefaultResourceDescriptionStrategy { |
| |
| private static final Logger LOG = Logger.getLogger(EntityResourceDescriptionStrategy.class); |
| |
| public static final String ENTITY_FQN = "entityFqn"; |
| public static final String ENTITY_IS_MAPPED_SUPER_CLASS = "entityIsMappedSuperClass"; |
| public static final String ENTITY_SUPER_TYPE = "entitySuperType"; |
| public static final String ENTITY_INHERITED_CLASS = "entityInheritedClass"; |
| |
| @Inject |
| CompilerPhases compilerPhases; |
| |
| @Override |
| public boolean createEObjectDescriptions(EObject eObject, IAcceptor<IEObjectDescription> acceptor) { |
| if (eObject instanceof LEntity) { |
| QualifiedName qualifiedName = getQualifiedNameProvider().getFullyQualifiedName(eObject); |
| if (qualifiedName != null) { |
| if (!qualifiedName.isEmpty()) { |
| LEntity entity = (LEntity) eObject; |
| Map<String, String> userData = Maps.newHashMapWithExpectedSize(2); |
| userData.put(ENTITY_FQN, qualifiedName.toString()); |
| userData.put(ENTITY_IS_MAPPED_SUPER_CLASS, new Boolean(entity.isMappedSuperclass()).toString()); |
| IEObjectDescription description = EObjectDescription.create(qualifiedName, eObject, userData); |
| acceptor.accept(description); |
| LOG.debug("Created Entity-EObjectDescription " + eObject.eClass().getName() + ": " + description.getQualifiedName()); |
| } |
| return true; |
| } |
| } |
| return super.createEObjectDescriptions(eObject, acceptor); |
| |
| } |
| } |