com.mysql.jdbc.StringUtils Java Examples

The following examples show how to use com.mysql.jdbc.StringUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ValidationUtils.java    From oncokb with GNU Affero General Public License v3.0 6 votes vote down vote up
private static String getTarget(String hugoSymbol, EvidenceType evidenceType, String alteration, String tumorType, String treatment) {
    List<String> items = new ArrayList<>();
    if (!StringUtils.isNullOrEmpty(hugoSymbol)) {
        items.add(hugoSymbol);
    }
    if (evidenceType != null) {
        items.add(evidenceType.name());
    }
    if (!StringUtils.isNullOrEmpty(alteration)) {
        items.add(alteration);
    }
    if (!StringUtils.isNullOrEmpty(tumorType)) {
        items.add(tumorType);
    }
    if (!StringUtils.isNullOrEmpty(treatment)) {
        items.add(treatment);
    }
    return String.join(" / ", items);
}
 
Example #2
Source File: EvidenceController.java    From oncokb with GNU Affero General Public License v3.0 6 votes vote down vote up
private Boolean isEmptyEvidence(Evidence queryEvidence) {
    EvidenceType evidenceType = queryEvidence.getEvidenceType();
    String knownEffect = queryEvidence.getKnownEffect();
    String description = queryEvidence.getDescription();
    LevelOfEvidence level = queryEvidence.getLevelOfEvidence();
    Set<Treatment> treatments = queryEvidence.getTreatments();
    if (description != null) {
        description = description.trim();
    }
    Boolean isEmpty = false;
    if (evidenceType.equals(EvidenceType.ONCOGENIC) || evidenceType.equals(EvidenceType.MUTATION_EFFECT)) {
        if (StringUtils.isNullOrEmpty(knownEffect) && StringUtils.isNullOrEmpty(description)) isEmpty = true;
    } else if (EvidenceTypeUtils.getTreatmentEvidenceTypes().contains(evidenceType)) {
        if (treatments == null && StringUtils.isNullOrEmpty(description)) isEmpty = true;
    } else if (evidenceType.equals(EvidenceType.DIAGNOSTIC_IMPLICATION) || evidenceType.equals(EvidenceType.PROGNOSTIC_IMPLICATION)) {
        if (level == null && StringUtils.isNullOrEmpty(description)) isEmpty = true;
    } else if (StringUtils.isNullOrEmpty(description)) {
        isEmpty = true;
    }
    return isEmpty;
}
 
Example #3
Source File: WarningServiceImpl.java    From fastdfs-zyc with GNU General Public License v2.0 6 votes vote down vote up
@Override
@Transactional(propagation = Propagation.REQUIRED)
public List<WarningUser> findWarUser(WarningUser wu,PageInfo pageInfo) throws IOException, MyException {
    //To change body of implemented methods use File | Settings | File Templates.
    List<WarningUser> warningUsers = new ArrayList<WarningUser>();
    Session session = getSession();
    StringBuilder queryString = new StringBuilder("from WarningUser as w ");
    if(!StringUtils.isNullOrEmpty(wu.getName())){
        queryString.append("where w.name like '%"+wu.getName()+"%'");
    }
    Query query = session.createQuery(queryString.toString());
    pageInfo.setTotalCount(query.list().size());
    query.setMaxResults(pageInfo.getNumPerPage());
    query.setFirstResult((pageInfo.getPageNum()-1)*pageInfo.getNumPerPage());
    warningUsers = query.list();
    return warningUsers;
}
 
Example #4
Source File: MvcConfigurationPublic.java    From oncokb with GNU Affero General Public License v3.0 6 votes vote down vote up
@Bean
public Docket publicApi() {
    String swaggerDescription = PropertiesUtils.getProperties(SWAGGER_DESCRIPTION);
    String finalDescription = StringUtils.isNullOrEmpty(swaggerDescription) ? SWAGGER_DEFAULT_DESCRIPTION : swaggerDescription;
    return new Docket(DocumentationType.SWAGGER_2)
        .groupName("Public APIs")
        .select()
        .apis(RequestHandlerSelectors.withMethodAnnotation(PublicApi.class))
        .build()
        .apiInfo(new ApiInfo(
            "OncoKB APIs",
            finalDescription,
            PUBLIC_API_VERSION,
            "https://www.oncokb.org/terms",
            new Contact("OncoKB", "https://www.oncokb.org", "[email protected]"),
            "Terms of Use",
            "https://www.oncokb.org/terms"
        ))
        .useDefaultResponseMessages(false);
}
 
Example #5
Source File: DbHelper.java    From crud-intellij-plugin with Apache License 2.0 6 votes vote down vote up
public List<String> getDatabases() {
    Connection conn = getConnection();
    try {
        DatabaseMetaData metaData = conn.getMetaData();
        ResultSet catalogs = metaData.getCatalogs();
        List<String> rs = new ArrayList<>();
        while (catalogs.next()) {
            String db = catalogs.getString("TABLE_CAT");
            if (org.apache.commons.lang3.StringUtils.equalsIgnoreCase(db, "information_schema")) {
                continue;
            }
            rs.add(db);
        }
        return rs;
    } catch (SQLException e) {
        throw new RuntimeException(e.getMessage(), e);
    } finally {
        closeConnection(conn);
    }
}
 
Example #6
Source File: MysqlClearPasswordPlugin.java    From Komondor with GNU General Public License v3.0 6 votes vote down vote up
public boolean nextAuthenticationStep(Buffer fromServer, List<Buffer> toServer) throws SQLException {
    toServer.clear();

    Buffer bresp;
    try {
        String encoding = this.connection.versionMeetsMinimum(5, 7, 6) ? this.connection.getPasswordCharacterEncoding() : "UTF-8";
        bresp = new Buffer(StringUtils.getBytes(this.password != null ? this.password : "", encoding));
    } catch (UnsupportedEncodingException e) {
        throw SQLError.createSQLException(Messages.getString("MysqlClearPasswordPlugin.1", new Object[] { this.connection.getPasswordCharacterEncoding() }),
                SQLError.SQL_STATE_GENERAL_ERROR, null);
    }

    bresp.setPosition(bresp.getBufLength());
    int oldBufLength = bresp.getBufLength();

    bresp.writeByte((byte) 0);

    bresp.setBufLength(oldBufLength + 1);
    bresp.setPosition(0);

    toServer.add(bresp);
    return true;
}
 
Example #7
Source File: DbHelper.java    From crud-intellij-plugin with Apache License 2.0 6 votes vote down vote up
private List<Column> getAllColumn(String tableName) {
    Connection conn = getConnection(db);
    try {
        DatabaseMetaData metaData = conn.getMetaData();
        ResultSet primaryKeys = metaData.getPrimaryKeys(null, null, tableName);
        String primaryKey = null;
        while (primaryKeys.next()) {
            primaryKey = primaryKeys.getString("COLUMN_NAME");
        }
        ResultSet rs = metaData.getColumns(null, null, tableName, null);
        List<Column> ls = new ArrayList<>();
        while (rs.next()) {
            String columnName = rs.getString("COLUMN_NAME");
            Column column = new Column(rs.getString("REMARKS"), columnName, rs.getInt("DATA_TYPE"));
            if (!StringUtils.isNullOrEmpty(primaryKey) && columnName.equals(primaryKey)) {
                column.setId(true);
            }
            ls.add(column);
        }
        return ls;
    } catch (SQLException e) {
        throw new RuntimeException(e.getMessage(), e);
    } finally {
        closeConnection(conn);
    }
}
 
Example #8
Source File: MysqlOldPasswordPlugin.java    From Komondor with GNU General Public License v3.0 6 votes vote down vote up
public boolean nextAuthenticationStep(Buffer fromServer, List<Buffer> toServer) throws SQLException {
    toServer.clear();

    Buffer bresp = null;

    String pwd = this.password;

    if (fromServer == null || pwd == null || pwd.length() == 0) {
        bresp = new Buffer(new byte[0]);
    } else {
        bresp = new Buffer(
                StringUtils.getBytes(Util.newCrypt(pwd, fromServer.readString().substring(0, 8), this.connection.getPasswordCharacterEncoding())));

        bresp.setPosition(bresp.getBufLength());
        int oldBufLength = bresp.getBufLength();

        bresp.writeByte((byte) 0);

        bresp.setBufLength(oldBufLength + 1);
        bresp.setPosition(0);
    }
    toServer.add(bresp);

    return true;
}
 
Example #9
Source File: BaseTestCase.java    From Komondor with GNU General Public License v3.0 6 votes vote down vote up
protected Connection getConnectionWithProps(String url, String propsList) throws SQLException {
    Properties props = new Properties();

    if (propsList != null) {
        List<String> keyValuePairs = StringUtils.split(propsList, ",", false);

        for (String kvp : keyValuePairs) {
            List<String> splitUp = StringUtils.split(kvp, "=", false);
            StringBuilder value = new StringBuilder();

            for (int i = 1; i < splitUp.size(); i++) {
                if (i != 1) {
                    value.append("=");
                }

                value.append(splitUp.get(i));

            }

            props.setProperty(splitUp.get(0).toString().trim(), value.toString());
        }
    }

    return getConnectionWithProps(url, props);
}
 
Example #10
Source File: Utils.java    From SugarOnRest with MIT License 6 votes vote down vote up
/**
 * Gets integer value from string data.
 *
 * @param value The value to convert.
 * @return The converted string value.
 */
private static int getInteger(String value) {

    if (StringUtils.isNullOrEmpty(value)) {
        return 0;
    }

    if (value.equalsIgnoreCase("null")) {
        return 0;
    }

    try {
        return Integer.parseInt(value);
    }
    catch (Exception exception) {

    }

    return Integer.MAX_VALUE;
}
 
Example #11
Source File: ConnectionTest.java    From r-course with MIT License 6 votes vote down vote up
public void testUseOldUTF8Behavior() throws Exception {

        Properties props = new Properties();
        props.setProperty("useOldUTF8Behavior", "true");
        props.setProperty("useUnicode", "true");
        props.setProperty("characterEncoding", "UTF-8");
        props.setProperty("logFactory", "com.mysql.jdbc.log.StandardLogger");
        props.setProperty("profileSQL", "true");
        StandardLogger.startLoggingToBuffer();

        try {
            getConnectionWithProps(props);

            assertTrue(StringUtils.indexOfIgnoreCase(StandardLogger.getBuffer().toString(), "SET NAMES utf8") == -1);
        } finally {
            StandardLogger.dropBuffer();
        }
    }
 
Example #12
Source File: StringRegressionTest.java    From Komondor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Tests character conversion bug.
 * 
 * @throws Exception
 *             if there is an internal error (which is a bug).
 */
public void testAsciiCharConversion() throws Exception {
    byte[] buf = new byte[10];
    buf[0] = (byte) '?';
    buf[1] = (byte) 'S';
    buf[2] = (byte) 't';
    buf[3] = (byte) 'a';
    buf[4] = (byte) 't';
    buf[5] = (byte) 'e';
    buf[6] = (byte) '-';
    buf[7] = (byte) 'b';
    buf[8] = (byte) 'o';
    buf[9] = (byte) 't';

    String testString = "?State-bot";
    String convertedString = StringUtils.toAsciiString(buf);

    for (int i = 0; i < convertedString.length(); i++) {
        System.out.println((byte) convertedString.charAt(i));
    }

    assertTrue("Converted string != test string", testString.equals(convertedString));
}
 
Example #13
Source File: WarningServiceImpl.java    From fastdfs-zyc with GNU General Public License v2.0 6 votes vote down vote up
@Override
@Transactional(propagation = Propagation.REQUIRED)
public List<WarningData> findWarning(WarningData wd,PageInfo pageInfo) throws IOException, MyException {
    //To change body of implemented methods use File | Settings | File Templates.
    List<WarningData> warningDatas = new ArrayList<WarningData>();
    Session session = getSession();
    StringBuilder queryString = new StringBuilder("from WarningData as wd ");
    if(!StringUtils.isNullOrEmpty(wd.getWdIpAddr())){
        queryString.append("where wd.wdIpAddr like '%"+wd.getWdIpAddr()+"%'");
    }
    Query query = session.createQuery(queryString.toString());
    pageInfo.setTotalCount(query.list().size());
    query.setMaxResults(pageInfo.getNumPerPage());
    query.setFirstResult((pageInfo.getPageNum()-1)*pageInfo.getNumPerPage());
    warningDatas = query.list();
    return warningDatas;
}
 
Example #14
Source File: TestModuleAction.java    From fastdfs-zyc with GNU General Public License v2.0 6 votes vote down vote up
@RequestMapping("/testDownLoad")
public ModelAndView testDownLoad(String pageNum, String pageSize,String keyForSearch) {
    ModelAndView mv = new ModelAndView("testModule/downLoadTest.jsp");
    List<Fdfs_file> list = testModuleService.getAllFileListByPage(pageNum, pageSize,keyForSearch);
    int countDownLoadFile = testModuleService.getCountDownLoadFile(keyForSearch);
    mv.addObject("testFileCount", countDownLoadFile);
    if(!StringUtils.isNullOrEmpty(keyForSearch)){
        mv.addObject("pageNum", "1");
    }else{
        mv.addObject("pageNum", pageNum);
    }
    mv.addObject("pageSize", pageSize);
    mv.addObject("testFileList", list);
    mv.addObject("keySearch",keyForSearch);
    return mv;
}
 
Example #15
Source File: ConnectionTest.java    From Komondor with GNU General Public License v3.0 6 votes vote down vote up
public void testUseOldUTF8Behavior() throws Exception {

        Properties props = new Properties();
        props.setProperty("useOldUTF8Behavior", "true");
        props.setProperty("useUnicode", "true");
        props.setProperty("characterEncoding", "UTF-8");
        props.setProperty("logFactory", "com.mysql.jdbc.log.StandardLogger");
        props.setProperty("profileSQL", "true");
        StandardLogger.startLoggingToBuffer();

        try {
            getConnectionWithProps(props);

            assertTrue(StringUtils.indexOfIgnoreCase(StandardLogger.getBuffer().toString(), "SET NAMES utf8") == -1);
        } finally {
            StandardLogger.dropBuffer();
        }
    }
 
Example #16
Source File: StringRegressionTest.java    From r-course with MIT License 6 votes vote down vote up
/**
 * Tests character conversion bug.
 * 
 * @throws Exception
 *             if there is an internal error (which is a bug).
 */
public void testAsciiCharConversion() throws Exception {
    byte[] buf = new byte[10];
    buf[0] = (byte) '?';
    buf[1] = (byte) 'S';
    buf[2] = (byte) 't';
    buf[3] = (byte) 'a';
    buf[4] = (byte) 't';
    buf[5] = (byte) 'e';
    buf[6] = (byte) '-';
    buf[7] = (byte) 'b';
    buf[8] = (byte) 'o';
    buf[9] = (byte) 't';

    String testString = "?State-bot";
    String convertedString = StringUtils.toAsciiString(buf);

    for (int i = 0; i < convertedString.length(); i++) {
        System.out.println((byte) convertedString.charAt(i));
    }

    assertTrue("Converted string != test string", testString.equals(convertedString));
}
 
Example #17
Source File: MysqlXAConnection.java    From r-course with MIT License 6 votes vote down vote up
private static void appendXid(StringBuilder builder, Xid xid) {
    byte[] gtrid = xid.getGlobalTransactionId();
    byte[] btrid = xid.getBranchQualifier();

    if (gtrid != null) {
        StringUtils.appendAsHex(builder, gtrid);
    }

    builder.append(',');
    if (btrid != null) {
        StringUtils.appendAsHex(builder, btrid);
    }

    builder.append(',');
    StringUtils.appendAsHex(builder, xid.getFormatId());
}
 
Example #18
Source File: MysqlClearPasswordPlugin.java    From r-course with MIT License 6 votes vote down vote up
public boolean nextAuthenticationStep(Buffer fromServer, List<Buffer> toServer) throws SQLException {
    toServer.clear();

    Buffer bresp;
    try {
        String encoding = this.connection.versionMeetsMinimum(5, 7, 6) ? this.connection.getPasswordCharacterEncoding() : "UTF-8";
        bresp = new Buffer(StringUtils.getBytes(this.password != null ? this.password : "", encoding));
    } catch (UnsupportedEncodingException e) {
        throw SQLError.createSQLException(Messages.getString("MysqlClearPasswordPlugin.1", new Object[] { this.connection.getPasswordCharacterEncoding() }),
                SQLError.SQL_STATE_GENERAL_ERROR, null);
    }

    bresp.setPosition(bresp.getBufLength());
    int oldBufLength = bresp.getBufLength();

    bresp.writeByte((byte) 0);

    bresp.setBufLength(oldBufLength + 1);
    bresp.setPosition(0);

    toServer.add(bresp);
    return true;
}
 
Example #19
Source File: TumorTypeUtilsTest.java    From oncokb with GNU Affero General Public License v3.0 5 votes vote down vote up
private String tumorTypesToString(List<TumorType> tumorTypes) {
    List<String> name = new ArrayList<>();
    for (TumorType tumorType : tumorTypes) {
        name.add(tumorType.getCode() == null ?
            ("M:" + tumorType.getMainType().getName()) : tumorType.getName());
    }
    return org.apache.commons.lang3.StringUtils.join(name, ", ");
}
 
Example #20
Source File: StringRegressionTest.java    From Komondor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Tests fix for BUG#25047 - StringUtils.indexOfIgnoreCaseRespectQuotes() isn't case-insensitive on the first character of the target.
 * 
 * UPD: Method StringUtils.indexOfIgnoreCaseRespectQuotes() was replaced by StringUtils.indexOfIgnoreCase()
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug25047() throws Exception {
    assertEquals(26, StringUtils.indexOfIgnoreCase(0, "insert into Test (TestID) values (?)", "VALUES", "`", "`", StringUtils.SEARCH_MODE__MRK_COM_WS));
    assertEquals(26, StringUtils.indexOfIgnoreCase(0, "insert into Test (TestID) VALUES (?)", "values", "`", "`", StringUtils.SEARCH_MODE__MRK_COM_WS));

    assertEquals(StringUtils.indexOfIgnoreCase(0, "insert into Test (TestID) values (?)", "VALUES", "`", "`", StringUtils.SEARCH_MODE__MRK_COM_WS),
            StringUtils.indexOfIgnoreCase(0, "insert into Test (TestID) VALUES (?)", "VALUES", "`", "`", StringUtils.SEARCH_MODE__MRK_COM_WS));
    assertEquals(StringUtils.indexOfIgnoreCase(0, "insert into Test (TestID) values (?)", "values", "`", "`", StringUtils.SEARCH_MODE__MRK_COM_WS),
            StringUtils.indexOfIgnoreCase(0, "insert into Test (TestID) VALUES (?)", "values", "`", "`", StringUtils.SEARCH_MODE__MRK_COM_WS));
}
 
Example #21
Source File: UserAction.java    From fastdfs-zyc with GNU General Public License v2.0 5 votes vote down vote up
@RequestMapping("/useradd")
public ModelAndView useradd(String id) throws IOException, MyException {
    ModelAndView mv = new ModelAndView("user/useradd.jsp");
    if(!StringUtils.isNullOrEmpty(id))
    {
        User user=userService.findById(id);
        mv.addObject("id",user.getId());
        mv.addObject("name",user.getName());
        mv.addObject("psword",user.getPsword());
        mv.addObject("power",user.getPower());
    }

    return mv;
}
 
Example #22
Source File: StringUtilsTest.java    From Komondor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Tests StringUtil.indexOfQuoteDoubleAware() method
 * 
 * @throws Exception
 */
public void testIndexOfQuoteDoubleAware() throws Exception {
    final String[] searchInDoubledQt = new String[] { "A 'strange' \"STRONG\" `SsStRiNg` to be searched in",
            "A ''strange'' \"\"STRONG\"\" ``SsStRiNg`` to be searched in" };

    assertEquals(-1, StringUtils.indexOfQuoteDoubleAware(null, null, 0));
    assertEquals(-1, StringUtils.indexOfQuoteDoubleAware(null, "'", 0));
    assertEquals(-1, StringUtils.indexOfQuoteDoubleAware("abc", null, 0));
    assertEquals(-1, StringUtils.indexOfQuoteDoubleAware("abc", "", 0));
    assertEquals(-1, StringUtils.indexOfQuoteDoubleAware("abc", "bcd", 0));
    assertEquals(0, StringUtils.indexOfQuoteDoubleAware("abc", "abc", 0));

    int qtPos = 0;
    assertEquals(2, qtPos = StringUtils.indexOfQuoteDoubleAware(searchInDoubledQt[0], "'", 0));
    assertEquals(10, qtPos = StringUtils.indexOfQuoteDoubleAware(searchInDoubledQt[0], "'", qtPos + 1));
    assertEquals(-1, StringUtils.indexOfQuoteDoubleAware(searchInDoubledQt[0], "'", qtPos + 1));
    assertEquals(12, qtPos = StringUtils.indexOfQuoteDoubleAware(searchInDoubledQt[0], "\"", 0));
    assertEquals(19, qtPos = StringUtils.indexOfQuoteDoubleAware(searchInDoubledQt[0], "\"", qtPos + 1));
    assertEquals(-1, StringUtils.indexOfQuoteDoubleAware(searchInDoubledQt[0], "\"", qtPos + 1));
    assertEquals(21, qtPos = StringUtils.indexOfQuoteDoubleAware(searchInDoubledQt[0], "`", 0));
    assertEquals(30, qtPos = StringUtils.indexOfQuoteDoubleAware(searchInDoubledQt[0], "`", qtPos + 1));
    assertEquals(-1, StringUtils.indexOfQuoteDoubleAware(searchInDoubledQt[0], "`", qtPos + 1));

    assertEquals(-1, StringUtils.indexOfQuoteDoubleAware(searchInDoubledQt[1], "'", 0));
    assertEquals(-1, StringUtils.indexOfQuoteDoubleAware(searchInDoubledQt[1], "\"", 0));
    assertEquals(-1, StringUtils.indexOfQuoteDoubleAware(searchInDoubledQt[1], "`", 0));
}
 
Example #23
Source File: validation.java    From oncokb with GNU Affero General Public License v3.0 5 votes vote down vote up
private static void getEmptyBiologicalVariants() {
    URL feedUrl = getFeedUrl(WorkSheetEntryEnum.EMPTY_BIOLOGICAL);
    if (feedUrl != null) {
        for (Gene gene : GeneUtils.getAllGenes()) {
            Set<BiologicalVariant> variants = MainUtils.getBiologicalVariants(gene);
            for (BiologicalVariant variant : variants) {
                if (variant.getOncogenic() == null || variant.getMutationEffect() == null
                    || (variant.getMutationEffectPmids().isEmpty() && variant.getMutationEffectAbstracts().isEmpty())) {

                    ListEntry row = new ListEntry();
                    setValue(row, "Gene", gene.getHugoSymbol());
                    setValue(row, "Alteration", variant.getVariant().getAlteration());
                    setValue(row, "Oncogenicity", variant.getOncogenic());
                    setValue(row, "MutationEffect", variant.getMutationEffect());
                    setValue(row, "PMIDs", org.apache.commons.lang3.StringUtils.join(variant.getMutationEffectPmids(), ", "));
                    Set<ArticleAbstract> articleAbstracts = variant.getMutationEffectAbstracts();
                    Set<String> abstracts = new HashSet<>();
                    for (ArticleAbstract articleAbstract : articleAbstracts) {
                        abstracts.add(articleAbstract.getAbstractContent());
                    }
                    setValue(row, "Abstracts", org.apache.commons.lang3.StringUtils.join(abstracts, ", "));
                    insertRowToEntry(feedUrl, row);
                }
            }
        }
    }
}
 
Example #24
Source File: validation.java    From oncokb with GNU Affero General Public License v3.0 5 votes vote down vote up
private static void printEvidences(URL feedUrl, Set<Evidence> evidences) {
    if (evidences != null && feedUrl != null) {
        for (Evidence evidence : evidences) {
            ListEntry row = new ListEntry();

            setValue(row, "Level", evidence.getLevelOfEvidence().getLevel());
            setValue(row, "Gene", evidence.getGene().getHugoSymbol());

            List<String> alterationNames = getAlterationNameByEvidence(evidence);

            setValue(row, "Variants", MainUtils.listToString(alterationNames, ", "));

            setValue(row, "Disease", getCancerType(evidence.getOncoTreeType()));
            Set<String> drugs = EvidenceUtils.getDrugs(Collections.singleton(evidence));
            List<String> drugList = new ArrayList<>(drugs);
            Collections.sort(drugList);
            setValue(row, "Drugs", org.apache.commons.lang3.StringUtils.join(drugList, ", "));
            Set<String> articles = EvidenceUtils.getPmids(Collections.singleton(evidence));
            List<String> articleList = new ArrayList<>(articles);
            Collections.sort(articleList);
            setValue(row, "PMIDs", org.apache.commons.lang3.StringUtils.join(articleList, ", "));
            setValue(row, "NumberOfPMIDs", Integer.toString(articleList.size()));

            Set<String> abstractContent = getAbstractContentFromEvidence(evidence);
            setValue(row, "Abstracts", org.apache.commons.lang3.StringUtils.join(abstractContent, ", "));
            insertRowToEntry(feedUrl, row);
        }
    }
}
 
Example #25
Source File: FusionUtils.java    From oncokb with GNU Affero General Public License v3.0 5 votes vote down vote up
public static List<Gene> getGenes(String query) {
    List<Gene> genes = new ArrayList<>();
    if (!StringUtils.isNullOrEmpty(query)) {
        List<String> geneStrsList = Arrays.asList(query.split("-"));

        for (String geneStr : geneStrsList) {
            Gene tmpGene = GeneUtils.getGeneByHugoSymbol(geneStr);
            if (tmpGene != null && !genes.contains(tmpGene)) {
                genes.add(tmpGene);
            }
        }
    }
    return genes;
}
 
Example #26
Source File: JDBC4UpdatableResultSet.java    From r-course with MIT License 5 votes vote down vote up
/**
 * JDBC 4.0 Update a column with NATIONAL CHARACTER. The updateXXX() methods
 * are used to update column values in the current row, or the insert row.
 * The updateXXX() methods do not update the underlying database, instead
 * the updateRow() or insertRow() methods are called to update the database.
 * 
 * @param columnIndex
 *            the first column is 1, the second is 2, ...
 * @param x
 *            the new column value
 * 
 * @exception SQLException
 *                if a database-access error occurs
 */
public void updateNString(int columnIndex, String x) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        String fieldEncoding = this.fields[columnIndex - 1].getEncoding();
        if (fieldEncoding == null || !fieldEncoding.equals("UTF-8")) {
            throw new SQLException("Can not call updateNString() when field's character set isn't UTF-8");
        }

        if (!this.onInsertRow) {
            if (!this.doingUpdates) {
                this.doingUpdates = true;
                syncUpdate();
            }

            ((com.mysql.jdbc.JDBC4PreparedStatement) this.updater).setNString(columnIndex, x);
        } else {
            ((com.mysql.jdbc.JDBC4PreparedStatement) this.inserter).setNString(columnIndex, x);

            if (x == null) {
                this.thisRow.setColumnValue(columnIndex - 1, null);
            } else {
                this.thisRow.setColumnValue(columnIndex - 1, StringUtils.getBytes(x, this.charConverter, fieldEncoding, this.connection.getServerCharset(),
                        this.connection.parserKnowsUnicode(), getExceptionInterceptor()));
            }
        }
    }
}
 
Example #27
Source File: validation.java    From oncokb with GNU Affero General Public License v3.0 5 votes vote down vote up
private static void printEvidenceDescriptionContent(URL feedUrl, Evidence Evidence, String type) {
    ListEntry row = new ListEntry();
    setValue(row, "Type", type);
    setValue(row, "Gene", Evidence.getGene().getHugoSymbol());
    setValue(row, "EvidenceID", Evidence.getId().toString());
    List<String> alterations = new ArrayList<>();
    for (Alteration alteration : Evidence.getAlterations()) {
        alterations.add(alteration.getAlteration());
    }
    setValue(row, "Alteration", org.apache.commons.lang3.StringUtils.join(alterations, ", "));
    insertRowToEntry(feedUrl, row);
}
 
Example #28
Source File: Sha256PasswordPlugin.java    From r-course with MIT License 5 votes vote down vote up
private static byte[] encryptPassword(String password, String seed, Connection connection, String key) throws SQLException {
    byte[] input = null;
    try {
        input = password != null ? StringUtils.getBytesNullTerminated(password, connection.getPasswordCharacterEncoding()) : new byte[] { 0 };
    } catch (UnsupportedEncodingException e) {
        throw SQLError.createSQLException(Messages.getString("Sha256PasswordPlugin.3", new Object[] { connection.getPasswordCharacterEncoding() }),
                SQLError.SQL_STATE_GENERAL_ERROR, null);
    }
    byte[] mysqlScrambleBuff = new byte[input.length];
    Security.xorString(input, mysqlScrambleBuff, seed.getBytes(), input.length);
    return ExportControlled.encryptWithRSAPublicKey(mysqlScrambleBuff,
            ExportControlled.decodeRSAPublicKey(key, ((MySQLConnection) connection).getExceptionInterceptor()),
            ((MySQLConnection) connection).getExceptionInterceptor());
}
 
Example #29
Source File: Sha256PasswordPlugin.java    From Komondor with GNU General Public License v3.0 5 votes vote down vote up
protected byte[] encryptPassword(String transformation) throws SQLException {
    byte[] input = null;
    try {
        input = this.password != null ? StringUtils.getBytesNullTerminated(this.password, this.connection.getPasswordCharacterEncoding())
                : new byte[] { 0 };
    } catch (UnsupportedEncodingException e) {
        throw SQLError.createSQLException(Messages.getString("Sha256PasswordPlugin.3", new Object[] { this.connection.getPasswordCharacterEncoding() }),
                SQLError.SQL_STATE_GENERAL_ERROR, null);
    }
    byte[] mysqlScrambleBuff = new byte[input.length];
    Security.xorString(input, mysqlScrambleBuff, this.seed.getBytes(), input.length);
    return ExportControlled.encryptWithRSAPublicKey(mysqlScrambleBuff,
            ExportControlled.decodeRSAPublicKey(this.publicKeyString, this.connection.getExceptionInterceptor()), transformation,
            this.connection.getExceptionInterceptor());
}
 
Example #30
Source File: validation.java    From oncokb with GNU Affero General Public License v3.0 5 votes vote down vote up
private static void printEvidencePmids(URL feedUrl, Evidence Evidence, String type, Set<String> pmids) {
    ListEntry row = new ListEntry();
    setValue(row, "Type", type);
    setValue(row, "Gene", Evidence.getGene().getHugoSymbol());
    setValue(row, "EvidenceID", Evidence.getId().toString());
    List<String> alterations = new ArrayList<>();
    for (Alteration alteration : Evidence.getAlterations()) {
        alterations.add(alteration.getAlteration());
    }
    setValue(row, "Alteration", org.apache.commons.lang3.StringUtils.join(alterations, ", "));
    setValue(row, "PMIDs", org.apache.commons.lang3.StringUtils.join(pmids, ", "));
    insertRowToEntry(feedUrl, row);
}