if (project != null)
{
JPAFacet<PersistenceCommonDescriptor> facet = project.getFacet(JPAFacet.class);
PersistenceContainer container = dataSource.getContainer();
PersistenceProvider provider = dataSource.getProvider();
PersistenceCommonDescriptor config = facet.getConfig();
PersistenceUnitCommon unit = null;
List<PersistenceUnitCommon> allPersistenceUnit = config.getAllPersistenceUnit();
for (PersistenceUnitCommon persistenceUnit : allPersistenceUnit)
{
if (unitName.equals(persistenceUnit.getName()))
{
unit = persistenceUnit;
break;
}
}
if (unit == null)
{
unit = config.createPersistenceUnit();
}
else
{
// FORGE-2049: Call all Remove methods until there is a decent way to do this in ShrinkWrap Descriptors
unit.removeAllClazz().removeAllJarFile().removeAllMappingFile().removeDescription()