Search in sources :

Example 1 with StableURL

use of gov.nih.nci.ctd2.dashboard.util.StableURL in project nci-ctd2-dashboard by CBIIT.

the class DashboardDaoImpl method createObservedSubjectInfo.

private List<SubjectItem> createObservedSubjectInfo(Integer observationId) {
    Session session1 = getSession();
    @SuppressWarnings("unchecked") org.hibernate.query.Query<Object[]> query1 = session1.createNativeQuery("SELECT d2.displayName AS role, observed_subject_role.displayText AS description, d1.displayName AS name, subject.id, columnName, stableURL" + " FROM observed_subject join subject on observed_subject.subject_id=subject.id" + " JOIN dashboard_entity d1 ON subject.id=d1.id" + " JOIN observed_subject_role ON observed_subject.observedSubjectRole_id = observed_subject_role.id" + " JOIN subject_role ON observed_subject_role.subjectRole_id=subject_role.id" + " JOIN dashboard_entity AS d2 ON subject_role.id=d2.id" + " where observation_id=" + observationId);
    List<Object[]> subjects = query1.list();
    List<SubjectItem> list = new ArrayList<SubjectItem>();
    for (Object[] obj : subjects) {
        String role = (String) obj[0];
        String description = (String) obj[1];
        String name = (String) obj[2];
        Integer subjectId = (Integer) obj[3];
        String columnName = (String) obj[4];
        String stableURL = (String) obj[5];
        @SuppressWarnings("unchecked") org.hibernate.query.Query<String> query2 = session1.createNativeQuery("SELECT displayName FROM subject_synonym_map " + " JOIN synonym ON subject_synonym_map.synonyms_id=synonym.id " + " JOIN dashboard_entity ON synonym.id = dashboard_entity.id" + " WHERE SubjectImpl_id=" + subjectId);
        List<String> synonyms = query2.list();
        @SuppressWarnings("unchecked") org.hibernate.query.Query<Object[]> query3 = session1.createNativeQuery("SELECT databaseId, databaseName FROM subject_xref_map" + " JOIN xref ON subject_xref_map.xrefs_id=xref.id " + " WHERE SubjectImpl_id=" + subjectId);
        List<Object[]> xrefs = query3.list();
        List<XRefItem> xrefItems = new ArrayList<XRefItem>();
        for (Object[] x : xrefs) {
            xrefItems.add(new XRefItem((String) x[1], (String) x[0]));
        }
        SubjectItem subjectItem = new SubjectItem(stableURL, role, description, name, synonyms.toArray(new String[0]), xrefItems.toArray(new XRefItem[0]), columnName);
        list.add(subjectItem);
    }
    session1.close();
    return list;
}
Also used : ArrayList(java.util.ArrayList) XRefItem(gov.nih.nci.ctd2.dashboard.api.XRefItem) SubjectItem(gov.nih.nci.ctd2.dashboard.api.SubjectItem) BigInteger(java.math.BigInteger) FullTextSession(org.hibernate.search.FullTextSession) Session(org.hibernate.Session)

Example 2 with StableURL

use of gov.nih.nci.ctd2.dashboard.util.StableURL in project nci-ctd2-dashboard by CBIIT.

the class DashboardDaoImpl method getSubjectCounts.

@Override
public WordCloudEntry[] getSubjectCounts() {
    List<WordCloudEntry> list = new ArrayList<WordCloudEntry>();
    String sql = "SELECT displayName, numberOfObservations, stableURL FROM subject_with_summaries" + " JOIN subject ON subject_with_summaries.subject_id=subject.id" + " JOIN dashboard_entity ON subject.id=dashboard_entity.id" + " WHERE score>1 ORDER BY numberOfObservations DESC LIMIT 250";
    Session session = getSession();
    @SuppressWarnings("unchecked") org.hibernate.query.Query<Object[]> query = session.createNativeQuery(sql);
    for (Object[] obj : query.getResultList()) {
        String subject = (String) obj[0];
        String fullname = null;
        if (subject.length() > ABBREVIATION_LENGTH_LIMIT) {
            fullname = subject;
            subject = shorternSubjectName(subject);
        }
        Integer count = (Integer) obj[1];
        String url = (String) obj[2];
        list.add(new WordCloudEntry(subject, count, url, fullname));
    }
    session.close();
    return list.toArray(new WordCloudEntry[0]);
}
Also used : BigInteger(java.math.BigInteger) ArrayList(java.util.ArrayList) WordCloudEntry(gov.nih.nci.ctd2.dashboard.util.WordCloudEntry) FullTextSession(org.hibernate.search.FullTextSession) Session(org.hibernate.Session)

Example 3 with StableURL

use of gov.nih.nci.ctd2.dashboard.util.StableURL in project nci-ctd2-dashboard by CBIIT.

the class TRCshRNADataProcessor method process.

@Override
public ShRna process(ShRna shRNA) throws Exception {
    if (shRNA == null)
        return null;
    if (shRNA.getOrganism() == null)
        return null;
    // allow null transcript relationship
    // if (shRNA.getTranscript() == null) return null;
    String stableURL = new StableURL().createURLWithPrefix("rna", shRNA.getTargetSequence());
    shRNA.setStableURL(stableURL);
    return shRNA;
}
Also used : StableURL(gov.nih.nci.ctd2.dashboard.util.StableURL)

Example 4 with StableURL

use of gov.nih.nci.ctd2.dashboard.util.StableURL in project nci-ctd2-dashboard by CBIIT.

the class GeneDataWriter method write.

public void write(List<? extends Gene> items) throws Exception {
    StableURL stableURL = new StableURL();
    for (Gene gene : items) {
        char species = gene.getOrganism().getDisplayName().charAt(0);
        species = Character.toLowerCase(species);
        gene.setStableURL(stableURL.createURLWithPrefix("gene/" + species, gene.getDisplayName()));
    }
    dashboardDao.batchSave(items, batchSize);
    log.debug("Gene written");
}
Also used : StableURL(gov.nih.nci.ctd2.dashboard.util.StableURL) Gene(gov.nih.nci.ctd2.dashboard.model.Gene)

Example 5 with StableURL

use of gov.nih.nci.ctd2.dashboard.util.StableURL in project nci-ctd2-dashboard by CBIIT.

the class TissueSampleDataWriter method execute.

public RepeatStatus execute(StepContribution arg0, ChunkContext arg1) throws Exception {
    ArrayList<DashboardEntity> entities = new ArrayList<DashboardEntity>();
    for (TissueSample tissueSample : tissueSampleMap.values()) {
        String nciThesaurusId = getNCIThesaurusID(tissueSample);
        String stableURL = new StableURL().createURLWithPrefix("tissue", nciThesaurusId);
        tissueSample.setStableURL(stableURL);
        entities.add(tissueSample);
    }
    dashboardDao.batchSave(entities, batchSize);
    return RepeatStatus.FINISHED;
}
Also used : StableURL(gov.nih.nci.ctd2.dashboard.util.StableURL)

Aggregations

StableURL (gov.nih.nci.ctd2.dashboard.util.StableURL)10 ArrayList (java.util.ArrayList)7 BigInteger (java.math.BigInteger)5 Session (org.hibernate.Session)5 FullTextSession (org.hibernate.search.FullTextSession)5 DashboardEntity (gov.nih.nci.ctd2.dashboard.model.DashboardEntity)3 WordCloudEntry (gov.nih.nci.ctd2.dashboard.util.WordCloudEntry)3 JSONSerializer (flexjson.JSONSerializer)2 ObservationItem (gov.nih.nci.ctd2.dashboard.api.ObservationItem)2 SubjectItem (gov.nih.nci.ctd2.dashboard.api.SubjectItem)2 ImplTransformer (gov.nih.nci.ctd2.dashboard.util.ImplTransformer)2 HttpHeaders (org.springframework.http.HttpHeaders)2 ResponseEntity (org.springframework.http.ResponseEntity)2 Transactional (org.springframework.transaction.annotation.Transactional)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 EvidenceItem (gov.nih.nci.ctd2.dashboard.api.EvidenceItem)1 ExcludeTransformer (gov.nih.nci.ctd2.dashboard.api.ExcludeTransformer)1 FieldNameTransformer (gov.nih.nci.ctd2.dashboard.api.FieldNameTransformer)1 SimpleDateTransformer (gov.nih.nci.ctd2.dashboard.api.SimpleDateTransformer)1 XRefItem (gov.nih.nci.ctd2.dashboard.api.XRefItem)1