Skip to content

Commit

Permalink
Merge branch 'feature/deactivated_institution' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
cslzchen committed Jun 24, 2021
2 parents 6f33f36 + c5d5635 commit ce906db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/main/java/io/cos/cas/osf/dao/JpaOsfDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,22 @@ public OsfTotp findOneTotpByOwnerId(final Integer ownerId) {
public OsfInstitution findOneInstitutionById(final String id) {
try {
final TypedQuery<OsfInstitution> 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);
return query.getSingleResult();
} catch (final PersistenceException e) {
return null;
}

}

@Override
public List<OsfInstitution> findAllInstitutions() {
try {
final TypedQuery<OsfInstitution> 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();
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/io/cos/cas/osf/model/OsfInstitution.java
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit ce906db

Please sign in to comment.