Search in sources :

Example 6 with EntityInfo

use of org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo in project jbosstools-hibernate by jbosstools.

the class EntitiesList method isOneProject.

public boolean isOneProject() {
    Map<String, EntityInfo> mapEntities = data.getEntities();
    Iterator<EntityInfo> it = mapEntities.values().iterator();
    boolean res = true;
    String javaProjectName = null;
    while (it.hasNext()) {
        EntityInfo ei = it.next();
        if (javaProjectName != null && !javaProjectName.equalsIgnoreCase(ei.getJavaProjectName())) {
            res = false;
            break;
        }
        javaProjectName = ei.getJavaProjectName();
    }
    return res;
}
Also used : EntityInfo(org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo)

Example 7 with EntityInfo

use of org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo in project jbosstools-hibernate by jbosstools.

the class ResolveAmbiguous method findRelatedRefFieldInfos.

protected Set<RefFieldInfo> findRelatedRefFieldInfos(String fullyQualifiedName, RefEntityInfo rei) {
    String fullyQualifiedName2 = rei.fullyQualifiedName;
    EntityInfo entryInfo2 = data.getEntities().get(fullyQualifiedName2);
    Set<RefFieldInfo> setRefEntityInfo = entryInfo2.getRefFieldInfoSet(fullyQualifiedName);
    return setRefEntityInfo;
}
Also used : RefEntityInfo(org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefEntityInfo) EntityInfo(org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo) RefFieldInfo(org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefFieldInfo)

Example 8 with EntityInfo

use of org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo in project jbosstools-hibernate by jbosstools.

the class AllEntitiesProcessor method reCollectModification.

public void reCollectModification(Map<String, EntityInfo> entities) {
    changes.clear();
    final ITextFileBufferManager bufferManager = FileBuffers.getTextFileBufferManager();
    HashMap<IPath, EntityInfosCollection> modifications = new HashMap<IPath, EntityInfosCollection>();
    Iterator<Map.Entry<String, EntityInfo>> it = entities.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry<String, EntityInfo> entry = it.next();
        if (entry.getValue().isInterfaceFlag()) {
            continue;
        }
        final String javaProjectName = entry.getValue().getJavaProjectName();
        final String fullyQualifiedName = entry.getValue().getFullyQualifiedName();
        IJavaProject javaProject = Utils.findJavaProject(javaProjectName);
        ICompilationUnit icu = Utils.findCompilationUnit(javaProject, fullyQualifiedName);
        if (icu == null) {
            continue;
        }
        org.eclipse.jdt.core.dom.CompilationUnit cu = Utils.getCompilationUnit(icu, true);
        final IPath path = cu.getJavaElement().getPath();
        EntityInfosCollection eiCollection = null;
        if (modifications.containsKey(path)) {
            eiCollection = modifications.get(path);
        } else {
            eiCollection = new EntityInfosCollection();
            eiCollection.setPath(path);
            eiCollection.setICompilationUnit(icu);
            eiCollection.setCompilationUnit(cu);
            modifications.put(path, eiCollection);
            try {
                bufferManager.connect(path, LocationKind.IFILE, null);
            } catch (CoreException e) {
                // $NON-NLS-1$
                HibernateConsolePlugin.getDefault().logErrorMessage("CoreException: ", e);
            }
        }
        final EntityInfo entityInfo = entry.getValue();
        // 
        entityInfo.updateColumnAnnotationImport(defaultStrLength != columnLength);
        entityInfo.updateVersionImport(enableOptLock && entityInfo.isAddVersionFlag());
        // 
        eiCollection.addEntityInfo(entityInfo);
    }
    Iterator<EntityInfosCollection> itEIC = modifications.values().iterator();
    while (itEIC.hasNext()) {
        EntityInfosCollection eic = itEIC.next();
        eic.updateExistingImportSet();
        eic.updateRequiredImportSet();
        collectModification(bufferManager, eic, entities);
    }
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) IPath(org.eclipse.core.runtime.IPath) ITextFileBufferManager(org.eclipse.core.filebuffers.ITextFileBufferManager) HashMap(java.util.HashMap) IJavaProject(org.eclipse.jdt.core.IJavaProject) CoreException(org.eclipse.core.runtime.CoreException) EntityInfosCollection(org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfosCollection) EntityInfo(org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo) HashMap(java.util.HashMap) Map(java.util.Map)

Example 9 with EntityInfo

use of org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo in project jbosstools-hibernate by jbosstools.

the class ResolveAmbiguous method findMappedRefEntityInfo.

protected RefEntityInfo findMappedRefEntityInfo(RefEntityInfo rei) {
    if (rei.mappedBy == null) {
        return null;
    }
    String fullyQualifiedName2 = rei.fullyQualifiedName;
    EntityInfo entryInfo2 = data.getEntities().get(fullyQualifiedName2);
    RefEntityInfo refEntityInfo = entryInfo2.getFieldIdRefEntityInfo(rei.mappedBy);
    return refEntityInfo;
}
Also used : RefEntityInfo(org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefEntityInfo) RefEntityInfo(org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefEntityInfo) EntityInfo(org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo)

Example 10 with EntityInfo

use of org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo in project jbosstools-hibernate by jbosstools.

the class TypeVisitor method setEntities.

public void setEntities(Map<String, EntityInfo> entities) {
    rootClasses.clear();
    Iterator<Map.Entry<String, EntityInfo>> it = entities.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry<String, EntityInfo> entry = it.next();
        EntityInfo entryInfo = entry.getValue();
        String className = entryInfo.getName();
        ITable table = service.newTable(className.toUpperCase());
        IPersistentClass rootClass = service.newRootClass();
        rootClass.setEntityName(entryInfo.getFullyQualifiedName());
        rootClass.setClassName(entryInfo.getFullyQualifiedName());
        rootClass.setProxyInterfaceName(entryInfo.getFullyQualifiedName());
        rootClass.setLazy(true);
        rootClass.setTable(table);
        // abstract or interface
        rootClass.setAbstract(entryInfo.isAbstractFlag());
        rootClasses.put(entryInfo.getFullyQualifiedName(), rootClass);
    }
    typeVisitor = new TypeVisitor(service, rootClasses);
}
Also used : Entry(java.util.Map.Entry) RefEntityInfo(org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefEntityInfo) EntityInfo(org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) HashMap(java.util.HashMap) Map(java.util.Map) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass)

Aggregations

EntityInfo (org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo)16 RefEntityInfo (org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefEntityInfo)10 Map (java.util.Map)7 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)6 HashMap (java.util.HashMap)4 TreeMap (java.util.TreeMap)3 IJavaProject (org.eclipse.jdt.core.IJavaProject)3 ArrayList (java.util.ArrayList)2 Entry (java.util.Map.Entry)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 AllEntitiesInfoCollector (org.hibernate.eclipse.jdt.ui.internal.jpa.collect.AllEntitiesInfoCollector)2 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)2 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 Set (java.util.Set)1 ITextFileBufferManager (org.eclipse.core.filebuffers.ITextFileBufferManager)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1 CompilationUnit (org.eclipse.jdt.core.dom.CompilationUnit)1 TypeDeclaration (org.eclipse.jdt.core.dom.TypeDeclaration)1