use of org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfosCollection 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);
}
}
Aggregations