/** * Create unique; if existing convert an existing {@link JNDIResourceModel} if one exists. */ public synchronized JNDIResourceModel createUnique(Set<ProjectModel> applications, String jndiName) { JNDIResourceModel jndiResourceModel = getUniqueByProperty(JNDIResourceModel.JNDI_LOCATION, jndiName); if (jndiResourceModel == null) { jndiResourceModel = super.create(); jndiResourceModel.setJndiLocation(jndiName); jndiResourceModel.setApplications(applications); } else { for (ProjectModel application : applications) { if (!jndiResourceModel.isAssociatedWithApplication(application)) jndiResourceModel.addApplication(application); } } return jndiResourceModel; }
/** * Indicates whether this {@link JNDIResourceModel} is associated with the given application. */ default boolean isAssociatedWithApplication(ProjectModel application) { boolean alreadyExists = false; for (ProjectModel existing : getApplications()) { if (existing.equals(application)) { alreadyExists = true; break; } } return alreadyExists; }
if (!jndi.isAssociatedWithApplication(application)) continue;
if (!jndi.isAssociatedWithApplication(application)) continue;
/** * Create unique; if existing convert an existing {@link JNDIResourceModel} if one exists. */ public synchronized JNDIResourceModel createUnique(Set<ProjectModel> applications, String jndiName) { JNDIResourceModel jndiResourceModel = getUniqueByProperty(JNDIResourceModel.JNDI_LOCATION, jndiName); if (jndiResourceModel == null) { jndiResourceModel = super.create(); jndiResourceModel.setJndiLocation(jndiName); jndiResourceModel.setApplications(applications); } else { for (ProjectModel application : applications) { if (!jndiResourceModel.isAssociatedWithApplication(application)) jndiResourceModel.addApplication(application); } } return jndiResourceModel; }
/** * Indicates whether this {@link JNDIResourceModel} is associated with the given application. */ default boolean isAssociatedWithApplication(ProjectModel application) { boolean alreadyExists = false; for (ProjectModel existing : getApplications()) { if (existing.equals(application)) { alreadyExists = true; break; } } return alreadyExists; }