use of org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo in project jbosstools-hibernate by jbosstools.
the class TypeVisitor method createConfiguration.
protected IConfiguration createConfiguration(IJavaProject project, Map<String, EntityInfo> entities) {
IConfiguration result = null;
IService service = getService(project);
if (service != null) {
result = service.newDefaultConfiguration();
ProcessEntityInfo processor = new ProcessEntityInfo(service);
processor.setEntities(entities);
for (Entry<String, EntityInfo> entry : entities.entrySet()) {
String fullyQualifiedName = entry.getValue().getFullyQualifiedName();
ICompilationUnit icu = Utils.findCompilationUnit(project, fullyQualifiedName);
if (icu != null) {
CompilationUnit cu = Utils.getCompilationUnit(icu, true);
processor.setEntityInfo(entry.getValue());
cu.accept(processor);
}
}
Collection<IPersistentClass> classesCollection = createHierarhyStructure(project, processor.getRootClasses());
for (IPersistentClass persistentClass : classesCollection) {
result.addClass(persistentClass);
}
}
return result;
}
use of org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo in project jbosstools-hibernate by jbosstools.
the class NewHibernateMappingFileWizard method initEntitiesInfo.
protected void initEntitiesInfo() {
if (selectionCU.size() == 0) {
return;
}
AllEntitiesInfoCollector collector = new AllEntitiesInfoCollector();
Iterator<ICompilationUnit> it = selectionCU.iterator();
Map<IJavaProject, Set<ICompilationUnit>> mapJP_CUSet = new HashMap<IJavaProject, Set<ICompilationUnit>>();
// separate by parent project
while (it.hasNext()) {
ICompilationUnit cu = it.next();
Set<ICompilationUnit> set = mapJP_CUSet.get(cu.getJavaProject());
if (set == null) {
set = new HashSet<ICompilationUnit>();
mapJP_CUSet.put(cu.getJavaProject(), set);
}
set.add(cu);
}
Iterator<Map.Entry<IJavaProject, Set<ICompilationUnit>>> mapIt = mapJP_CUSet.entrySet().iterator();
while (mapIt.hasNext()) {
Map.Entry<IJavaProject, Set<ICompilationUnit>> entry = mapIt.next();
IJavaProject javaProject = entry.getKey();
Iterator<ICompilationUnit> setIt = entry.getValue().iterator();
collector.initCollector();
while (setIt.hasNext()) {
ICompilationUnit icu = setIt.next();
collector.collect(icu, processDepth);
}
collector.resolveRelations();
Collection<EntityInfo> c = new ArrayList<EntityInfo>();
for (Iterator<EntityInfo> i = collector.getMapCUs_Info().values().iterator(); i.hasNext(); ) {
c.add(i.next());
}
project_infos.put(javaProject, c);
}
}
use of org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo in project jbosstools-hibernate by jbosstools.
the class HibernateJPAWizardDataFactory method createHibernateJPAWizardData.
public static IHibernateJPAWizardData createHibernateJPAWizardData(final IStructuredSelection selection2Update, IHibernateJPAWizardParams params, int depth) {
CompilationUnitCollector compileUnitCollector = new CompilationUnitCollector();
@SuppressWarnings("rawtypes") Iterator itSelection2Update = selection2Update.iterator();
while (itSelection2Update.hasNext()) {
Object obj = itSelection2Update.next();
compileUnitCollector.processJavaElements(obj, true);
}
Iterator<ICompilationUnit> it = compileUnitCollector.setSelectionCUIterator();
AllEntitiesInfoCollector collector = new AllEntitiesInfoCollector();
collector.initCollector();
while (it.hasNext()) {
ICompilationUnit cu = it.next();
collector.collect(cu, depth);
}
collector.resolveRelations();
final Map<String, EntityInfo> entities = collector.getMapCUs_Info();
params.performDisconnect();
params.reCollectModification(entities);
final ArrayList<ChangeStructure> changes = params.getChanges();
IHibernateJPAWizardData data = new IHibernateJPAWizardData() {
public Map<String, EntityInfo> getEntities() {
return entities;
}
public ArrayList<ChangeStructure> getChanges() {
return changes;
}
public IStructuredSelection getSelection2Update() {
return selection2Update;
}
};
return data;
}
use of org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo in project jbosstools-hibernate by jbosstools.
the class JPAMapToolActor method updateSelected.
/**
* updates selected compilation units collection
* @param depth - process depth
*/
public void updateSelected(int depth) {
if (selection != null) {
updateSelectedItems(selection);
selection = null;
} else {
if (getSelectionCUSize() == 0) {
updateOpen(depth);
return;
}
}
if (getSelectionCUSize() == 0) {
Map<String, EntityInfo> mapCUs_Info = new HashMap<String, EntityInfo>();
IStructuredSelection selection2Update = createSelection2Update();
processor.modify(mapCUs_Info, true, selection2Update);
return;
}
Iterator<ICompilationUnit> it = compileUnitCollector.setSelectionCUIterator();
collector.initCollector();
while (it.hasNext()) {
ICompilationUnit cu = it.next();
collector.collect(cu, depth);
}
collector.resolveRelations();
if (collector.getNonInterfaceCUNumber() > 0) {
processor.setAnnotationStylePreference(collector.getAnnotationStylePreference());
Map<String, EntityInfo> mapCUs_Info = collector.getMapCUs_Info();
IStructuredSelection selection2Update = createSelection2Update();
processor.modify(mapCUs_Info, true, selection2Update);
} else {
MessageDialog.openInformation(getShell(), JdtUiMessages.JPAMapToolActor_message_title, JdtUiMessages.JPAMapToolActor_message);
}
processor.savePreferences();
}
use of org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo in project jbosstools-hibernate by jbosstools.
the class AllEntitiesInfoCollector method adjustParentId.
public void adjustParentId(EntityInfo ei) {
if (ei == null) {
return;
}
// $NON-NLS-1$
EntityInfo parentEI = mapCUs_Info.get(ei.getJavaProjectName() + "/" + ei.getFullyQualifiedParentName());
adjustParentId(parentEI);
ei.adjustPrimaryId(parentEI);
}
Aggregations