protected void generate() { PersistenceUnit persistenceUnit = this.getPersistenceUnits().iterator().next(); // Take the first persistenceUnit String puName = persistenceUnit.getName(); EclipseLinkGenerateDDLWizard wizard = this.buildGenerateDDLWizard(this.project, puName); WizardDialog wizardDialog = new WizardDialog(this.getCurrentShell(), wizard); wizardDialog.create(); if (wizard.getPageCount() > 0) { wizardDialog.open(); } }
private void exec() { try { synchronized (jptsToUpdate) { Iterator<String> itr = jptsToUpdate.iterator(); if (itr.hasNext()) { String jptName = itr.next(); PersistentType jpt = (PersistentType) featureProvider.getBusinessObjectForKey(jptName); try { JpaArtifactFactory.instance().remakeRelations(featureProvider, null, jpt); jptsToUpdate.remove(jptName); } catch (RuntimeException e) { } } } Collection<Object> vals = solver.getVisualizedObjects(); Iterator<Object> it = vals.iterator(); while (it.hasNext()) { Object o = it.next(); if (o instanceof PersistentType) { PersistentType jpt = (PersistentType) o; final ContainerShape entShape = (ContainerShape) featureProvider.getPictogramElementForBusinessObject(o); if (entShape == null) continue; PersistenceUnit pu = JpaArtifactFactory.instance().getPersistenceUnit(jpt); PersistentType pt = pu.getPersistentType(jpt.getName()); if ((pt == null) || !JpaArtifactFactory.instance().isAnyKindPersistentType(jpt)) { JpaArtifactFactory.instance().forceSaveEntityClass(jpt, featureProvider); if (jpt.getMapping() == null || (jpt.getMapping() instanceof JavaNullTypeMapping)) { if (!JpaPreferences.getDiscoverAnnotatedClasses(jpt.getJpaProject().getProject())) { JPAEditorUtil.createUnregisterEntityFromXMLJob( jpt.getJpaProject(), jpt.getName()); } } RemoveContext ctx = new RemoveContext(entShape); RemoveAndSaveEntityFeature ft = new RemoveAndSaveEntityFeature(featureProvider); ft.remove(ctx); break; } } } synchronized (attribsToUpdate) { Set<String> atSet = attribsToUpdate.keySet(); Iterator<String> iter = atSet.iterator(); while (iter.hasNext()) { String jptAtMB = iter.next(); String[] jptAndAttrib = jptAtMB.split(SEPARATOR); PersistenceUnit pu = attribsToUpdate.get(jptAtMB); String entityName = jptAndAttrib[0]; String attribName = jptAndAttrib[1]; String mappedBy = jptAndAttrib[2]; String oldMappedBy = jptAndAttrib[3]; PersistentType jpt = pu.getPersistentType(entityName); if (jpt != null) { PersistentAttribute jpa = jpt.getAttributeNamed(attribName); if (jpa != null) { AttributeMapping mapping = JpaArtifactFactory.instance().getAttributeMapping(jpa); if (mapping instanceof RelationshipMapping) { RelationshipMapping relationshipMapping = (RelationshipMapping) mapping; MappedByRelationship ownableRef = (MappedByRelationship) relationshipMapping.getRelationship(); SpecifiedMappedByRelationshipStrategy mappedByStrategy = ownableRef.getMappedByStrategy(); String mappedByAttr = mappedByStrategy.getMappedByAttribute(); String[] mappedByAttrs = mappedByAttr.split(JPAEditorConstants.MAPPED_BY_ATTRIBUTE_SPLIT_SEPARATOR); if (mappedByAttrs.length > 1) { if (mappedByAttrs[0].equals(oldMappedBy)) { mappedByAttr = mappedBy + JPAEditorConstants.MAPPED_BY_ATTRIBUTE_SEPARATOR + mappedByAttrs[1]; } else if (mappedByAttrs[1].equals(oldMappedBy)) { mappedByAttr = mappedByAttrs[0] + JPAEditorConstants.MAPPED_BY_ATTRIBUTE_SEPARATOR + mappedBy; } } else { mappedByAttr = mappedBy; } mappedByStrategy.setMappedByAttribute(mappedByAttr); attribsToUpdate.remove(jptAtMB); } } } } } } catch (Exception e) { // ignore } }