Commit 453c7db4 authored by Matija Obreza's avatar Matija Obreza
Browse files

Include pgrActivity, maintColl in WIEWS institute data (allows for

filtering out non PGR organizations)
parent 6ac9343a
......@@ -57,6 +57,8 @@ public class FaoInstitute extends GeoEntity implements EntityId, java.io.Seriali
private String acronym;
private Country country;
private long accessionCount;
private boolean pgrActivity;
private boolean maintainsCollection;
public FaoInstitute() {
}
......@@ -164,4 +166,20 @@ public class FaoInstitute extends GeoEntity implements EntityId, java.io.Seriali
public void setAccessionCount(long accessionCount) {
this.accessionCount = accessionCount;
}
public boolean isMaintainsCollection() {
return maintainsCollection;
}
public void setMaintainsCollection(boolean maintainsCollection) {
this.maintainsCollection = maintainsCollection;
}
public boolean isPgrActivity() {
return pgrActivity;
}
public void setPgrActivity(boolean pgrActivity) {
this.pgrActivity = pgrActivity;
}
}
......@@ -34,14 +34,18 @@ public interface FaoInstituteRepository extends
@Query("select distinct(type) from FaoInstitute")
List<String> findTypes();
List<FaoInstitute> findByCountry(Country country, Sort sort);
@Query("from FaoInstitute fi where fi.country = ?1 and fi.pgrActivity=true")
List<FaoInstitute> listByCountry(Country country, Sort sort);
@Query("from FaoInstitute fi where fi.country = ?1 and fi.accessionCount > 0")
List<FaoInstitute> findByCountryActive(Country country, Sort sort);
@Query("from FaoInstitute fi where fi.accessionCount > 0")
Page<FaoInstitute> findAllActive(Pageable pageable);
Page<FaoInstitute> listAllActive(Pageable pageable);
@Query("from FaoInstitute fi where fi.code in ( ?1 )")
List<FaoInstitute> findAllByCodes(Collection<String> wiewsCodes);
@Query("from FaoInstitute fi where fi.pgrActivity=true")
Page<FaoInstitute> listInstitutes(Pageable pageable);
}
......@@ -65,12 +65,12 @@ public class InstituteServiceImpl implements InstituteService {
@Override
public Page<FaoInstitute> list(Pageable pageable) {
return instituteRepository.findAll(pageable);
return instituteRepository.listInstitutes(pageable);
}
@Override
public Page<FaoInstitute> listActive(PageRequest pageRequest) {
return instituteRepository.findAllActive(pageRequest);
return instituteRepository.listAllActive(pageRequest);
}
@Override
......@@ -80,7 +80,7 @@ public class InstituteServiceImpl implements InstituteService {
@Override
public List<FaoInstitute> listByCountry(Country country) {
return instituteRepository.findByCountry(country, new Sort("code"));
return instituteRepository.listByCountry(country, new Sort("code"));
}
@Override
......
......@@ -153,15 +153,15 @@ public class InstituteUpdater {
private void workIt(final Map<String, String[]> batch) {
// while (threadPool.getQueue().size() > nThreads) {
// LOG.warn("Queue is too large, waiting...");
// try {
// Thread.sleep(100);
// } catch (final InterruptedException e) {
// LOG.warn(e.getMessage());
// }
// }
// while (threadPool.getQueue().size() > nThreads) {
// LOG.warn("Queue is too large, waiting...");
// try {
// Thread.sleep(100);
// } catch (final InterruptedException e) {
// LOG.warn(e.getMessage());
// }
// }
// Need copy!
final Map<String, String[]> batchCopy = new HashMap<String, String[]>(batch);
......@@ -198,12 +198,12 @@ public class InstituteUpdater {
LOG.info("Updating FaoInstitutes: " + toSave.size());
instituteService.update(toSave);
}
// try {
// Thread.sleep(2000);
// } catch (final InterruptedException e) {
// LOG.warn(e.getMessage());
// }
// try {
// Thread.sleep(2000);
// } catch (final InterruptedException e) {
// LOG.warn(e.getMessage());
// }
}
private FaoInstitute insertData(String[] line) {
......@@ -218,8 +218,8 @@ public class InstituteUpdater {
// final String ecpaAcronym = line[2];
final String fullName = line[3];
final String type = line[4];
// final String pgrActivity = line[5];
// final String maintColl = line[6];
final boolean pgrActivity = "Y".equals(line[5]);
final boolean maintColl = "Y".equals(line[6]);
// final String streetPob = line[7];
// final String cityState = line[8];
// final String zipCode = line[9];
......@@ -239,6 +239,8 @@ public class InstituteUpdater {
faoInstitute.setAcronym(acronym);
faoInstitute.setFullName(fullName);
LOG.info("Updating: " + fullName);
faoInstitute.setPgrActivity(pgrActivity);
faoInstitute.setMaintainsCollection(maintColl);
faoInstitute.setEmail(email);
faoInstitute.setType(type);
faoInstitute.setUrl(url);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment