use of org.hibernate.eclipse.jdt.ui.internal.jpa.collect.AllEntitiesInfoCollector in project jbosstools-hibernate by jbosstools.
the class TypeVisitor method createConfigurations.
/**
* @return different configuration for different projects
*/
public Map<IJavaProject, IConfiguration> createConfigurations(int processDepth) {
Map<IJavaProject, IConfiguration> configs = new HashMap<IJavaProject, IConfiguration>();
if (selectionCU.size() == 0) {
return configs;
}
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();
// I don't check here if any non abstract class selected
IConfiguration config = createConfiguration(javaProject, collector.getMapCUs_Info());
if (config != null) {
configs.put(javaProject, config);
}
}
return configs;
}
use of org.hibernate.eclipse.jdt.ui.internal.jpa.collect.AllEntitiesInfoCollector in project jbosstools-hibernate by jbosstools.
the class JPAMapMockTests method testJPAMapToolActor.
public void testJPAMapToolActor() {
final JPAMapToolActor jpaMapToolActor = new JPAMapToolActor();
final AllEntitiesProcessor allEntitiesProcessor = context.mock(AllEntitiesProcessor.class);
final AllEntitiesInfoCollector allEntitiesInfoCollector = context.mock(AllEntitiesInfoCollector.class);
final ISelection selection = context.mock(ISelection.class);
final ICompilationUnit compilationUnit = context.mock(ICompilationUnit.class);
final IJavaProject javaProject = context.mock(IJavaProject.class);
jpaMapToolActor.setAllEntitiesProcessor(allEntitiesProcessor);
jpaMapToolActor.setAllEntitiesInfoCollector(allEntitiesInfoCollector);
jpaMapToolActor.setSelection(selection);
final IStructuredSelection selection2Update = new StructuredSelection();
context.checking(new Expectations() {
{
exactly(1).of(allEntitiesProcessor).modify(new HashMap<String, EntityInfo>(), true, selection2Update);
}
});
jpaMapToolActor.updateSelected(Integer.MAX_VALUE);
context.assertIsSatisfied();
jpaMapToolActor.setSelection(null);
Set<ICompilationUnit> selectionCU = new HashSet<ICompilationUnit>();
selectionCU.add(compilationUnit);
jpaMapToolActor.setSelectionCU(selectionCU);
// $NON-NLS-1$
final Sequence sequence = context.sequence("updateSelected");
context.checking(new Expectations() {
{
allowing(compilationUnit).getJavaProject();
inSequence(sequence);
will(returnValue(javaProject));
allowing(allEntitiesInfoCollector).initCollector();
inSequence(sequence);
allowing(allEntitiesInfoCollector).collect(compilationUnit, Integer.MAX_VALUE);
inSequence(sequence);
allowing(allEntitiesInfoCollector).resolveRelations();
inSequence(sequence);
allowing(allEntitiesInfoCollector).getNonAbstractCUNumber();
inSequence(sequence);
will(returnValue(2));
allowing(allEntitiesInfoCollector).getNonInterfaceCUNumber();
inSequence(sequence);
will(returnValue(2));
allowing(allEntitiesInfoCollector).getAnnotationStylePreference();
inSequence(sequence);
will(returnValue(AnnotStyle.GETTERS));
allowing(allEntitiesProcessor).setAnnotationStylePreference(AnnotStyle.GETTERS);
inSequence(sequence);
allowing(allEntitiesInfoCollector).getMapCUs_Info();
inSequence(sequence);
will(returnValue(null));
allowing(allEntitiesProcessor).modify(null, true, null);
inSequence(sequence);
allowing(allEntitiesProcessor).savePreferences();
inSequence(sequence);
exactly(1).of(allEntitiesProcessor).modify(null, true, selection2Update);
}
});
jpaMapToolActor.updateSelected(Integer.MAX_VALUE);
context.assertIsSatisfied();
/**
* /
* jpaMapToolActor.clearSelectionCU();
* jpaMapToolActor.addCompilationUnit(compilationUnit);
* jpaMapToolActor.addCompilationUnit(compilationUnit);
* context.checking(new Expectations() {{
* jpaMapToolActor.expects(once()).method("updateSelectedItems").with(eq(selection));
* one(authorizedPurchaserManager).retrievePurchasers(user.getId());
* will(returnValue(Collections.emptyList()));
*
* allowing(securityContext).getAuthentication();
* will(returnValue(authentication));
* }});
* jpaMapToolActor.updateOpen();
* /*
*/
}
use of org.hibernate.eclipse.jdt.ui.internal.jpa.collect.AllEntitiesInfoCollector 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.collect.AllEntitiesInfoCollector 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;
}
Aggregations