diff --git a/src/main/java/io/cos/cas/osf/dao/JpaOsfDao.java b/src/main/java/io/cos/cas/osf/dao/JpaOsfDao.java index 34fa6c52..efe580e3 100644 --- a/src/main/java/io/cos/cas/osf/dao/JpaOsfDao.java +++ b/src/main/java/io/cos/cas/osf/dao/JpaOsfDao.java @@ -100,7 +100,7 @@ public OsfTotp findOneTotpByOwnerId(final Integer ownerId) { public OsfInstitution findOneInstitutionById(final String id) { try { final TypedQuery query = entityManager.createQuery( - "select i from OsfInstitution i where i.institutionId = :id", + "select i from OsfInstitution i where i.institutionId = :id and i.deleted = false and i.dateDeactivated is null", OsfInstitution.class ); query.setParameter("id", id); @@ -108,7 +108,6 @@ public OsfInstitution findOneInstitutionById(final String id) { } catch (final PersistenceException e) { return null; } - } @Override @@ -116,7 +115,7 @@ public List findAllInstitutions() { try { final TypedQuery query = entityManager.createQuery( "select i from OsfInstitution i " - + "where (not i.delegationProtocol = '') and i.deleted = false", + + "where (not i.delegationProtocol = '') and i.deleted = false and i.dateDeactivated is null", OsfInstitution.class ); return query.getResultList(); diff --git a/src/main/java/io/cos/cas/osf/model/OsfInstitution.java b/src/main/java/io/cos/cas/osf/model/OsfInstitution.java index 9c80ea43..b085d232 100644 --- a/src/main/java/io/cos/cas/osf/model/OsfInstitution.java +++ b/src/main/java/io/cos/cas/osf/model/OsfInstitution.java @@ -9,6 +9,9 @@ import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import java.util.Date; /** * This is {@link OsfInstitution}. @@ -43,6 +46,10 @@ public class OsfInstitution extends AbstractOsfModel { @Column(name = "is_deleted") private Boolean deleted; + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "deactivated") + private Date dateDeactivated; + public DelegationProtocol getDelegationProtocol() { try { return DelegationProtocol.getType(delegationProtocol);