Search in sources :

Example 6 with GetConfig

use of massbank.GetConfig in project MassBank-web by MassBank.

the class OpenDataUpdater method run.

/**
 * Starting the thread.
 */
public void run() {
    try {
        sleep(this.startDelay * TIME_SEC);
    } catch (Exception e) {
    }
    GetConfig conf = new GetConfig(MassBankEnv.get(MassBankEnv.KEY_BASE_URL));
    String myServerUrl = conf.getServerUrl();
    String[] urls = conf.getSiteUrl();
    String[] names = conf.getSiteName();
    String[] dbNames = conf.getDbName();
    String[] dbNames2 = conf.getSecondaryDBName();
    ArrayList<String> targetNameList = new ArrayList();
    ArrayList<String> targetDbNameList = new ArrayList();
    for (int i = 0; i < names.length; i++) {
        if (!urls[i].equals(myServerUrl) && !dbNames2[i].equals("")) {
            targetNameList.add(names[i]);
            targetDbNameList.add(dbNames2[i]);
        } else {
            targetNameList.add(names[i]);
            targetDbNameList.add(dbNames[i]);
        }
    }
    String[] targetNames = targetNameList.toArray(new String[] {});
    String[] targetDbNames = targetDbNameList.toArray(new String[] {});
    String dataRootPath = MassBankEnv.get(MassBankEnv.KEY_DATAROOT_PATH);
    if (targetNames.length == 0) {
        return;
    }
    do {
        for (int i = 0; i < targetNames.length; i++) {
            String repoDirName = targetNames[i];
            String dbName = targetDbNames[i];
            logger.info("[SVNService] OpenDataUpdater ** " + repoDirName + " **");
            String workCopyPath = SVNUtils.getWorkCopyPath(repoDirName, SVNOperation.WC_OPEN_DATA);
            this.srcRecordPath = dataRootPath + "annotation" + File.separator + dbName;
            this.destRecordPath = workCopyPath;
            File file = new File(srcRecordPath);
            if (file.exists()) {
                String[] fileNames = file.list();
                if (fileNames.length > 0) {
                    for (int j = 0; j < fileNames.length; j++) {
                        fileNames[j] = srcRecordPath + File.separator + fileNames[j];
                    }
                    String[] filePaths = SVNUtils.getLicenseOKFileList(fileNames);
                    if (filePaths.length > 0 && !isFileUpdating()) {
                        registerData(repoDirName);
                    }
                }
            }
            try {
                sleep(this.interval * TIME_SEC);
            } catch (Exception e) {
            }
            if (this.isTerminated) {
                return;
            }
        }
    } while (true);
}
Also used : GetConfig(massbank.GetConfig) ArrayList(java.util.ArrayList) File(java.io.File)

Example 7 with GetConfig

use of massbank.GetConfig in project MassBank-web by MassBank.

the class RegistrationCommitter method run.

/**
 * Starting the thread.
 */
public void run() {
    try {
        sleep(this.startDelay * TIME_SEC);
    } catch (Exception e) {
    }
    this.isActive = true;
    GetConfig conf = new GetConfig(MassBankEnv.get(MassBankEnv.KEY_BASE_URL));
    String myServerUrl = conf.getServerUrl();
    String[] urls = conf.getSiteUrl();
    String[] names = conf.getSiteName();
    String[] dbNames = conf.getDbName();
    ArrayList<String> targetNameList = new ArrayList();
    ArrayList<String> targetDbNameList = new ArrayList();
    for (int i = 0; i < urls.length; i++) {
        if (i == 0 || urls[i].equals(myServerUrl)) {
            targetNameList.add(names[i]);
            targetDbNameList.add(dbNames[i]);
        }
    }
    String[] targetNames = targetNameList.toArray(new String[] {});
    String[] targetDbNames = targetDbNameList.toArray(new String[] {});
    String tempPath = System.getProperty("java.io.tmpdir");
    String dumpFilePath = tempPath + File.separator + "massbank_backup.sql";
    String[] tableNames = { "SPECTRUM", "RECORD", "PEAK", "CH_NAME", "CH_LINK", "INSTRUMENT", "TREE", "MOLFILE" };
    if (targetNames.length == 0) {
        return;
    }
    do {
        for (int i = 0; i < targetNames.length; i++) {
            String repoDirName = targetNames[i];
            String dbName = targetDbNames[i];
            logger.info("[SVNService] RegistrationCommitter ** " + repoDirName + " **");
            SVNOperation ope = null;
            try {
                ope = new SVNOperation(repoDirName, SVNOperation.WC_BACKUP_UPLOAD);
                if (ope.isWcModified()) {
                    boolean ret = FileUtil.execSqlDump("", dbName, tableNames, dumpFilePath);
                    if (ret) {
                        ope.addEntry(new String[] { dumpFilePath }, "other");
                        ope.commit();
                        FileUtils.deleteQuietly(new File(dumpFilePath));
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            ope.end();
            try {
                sleep(this.interval * TIME_SEC);
            } catch (Exception e) {
            }
            if (this.isTerminated) {
                return;
            }
        }
    } while (true);
}
Also used : GetConfig(massbank.GetConfig) ArrayList(java.util.ArrayList) File(java.io.File)

Example 8 with GetConfig

use of massbank.GetConfig in project MassBank-web by MassBank.

the class SVNRegisterUtil method update.

/**
 * Update to the svn
 */
private static boolean update(String targetDbName, boolean isRecord) {
    String baseUrl = MassBankEnv.get(MassBankEnv.KEY_BASE_URL);
    GetConfig conf = new GetConfig(baseUrl);
    String[] confNames = conf.getSiteName();
    String[] confDbNames = conf.getDbName();
    boolean found = false;
    int i = 0;
    for (i = 0; i < confDbNames.length; i++) {
        if (targetDbName.equals(confDbNames[i])) {
            found = true;
            break;
        }
    }
    if (!found) {
        return false;
    }
    String basePath = "";
    String[] extensions = null;
    String subDirName = "";
    if (isRecord) {
        basePath = MassBankEnv.get(MassBankEnv.KEY_ANNOTATION_PATH);
        extensions = new String[] { "txt" };
        subDirName = "record";
    } else {
        basePath = MassBankEnv.get(MassBankEnv.KEY_MOLFILE_PATH);
        extensions = new String[] { "mol", "tsv" };
        subDirName = "molfile";
    }
    String repoDirName = confNames[i];
    String path1 = basePath + targetDbName;
    String path2 = SVNUtils.getWorkCopyPath(repoDirName, SVNOperation.WC_BACKUP_UPLOAD) + File.separator + subDirName;
    SVNOperation ope = null;
    try {
        ope = new SVNOperation(repoDirName, SVNOperation.WC_BACKUP_UPLOAD);
        File dir1 = new File(path1);
        File dir2 = new File(path2);
        if (!dir2.exists()) {
            dir2.mkdirs();
        }
        List<File> fileList1 = (List<File>) FileUtils.listFiles(dir1, extensions, false);
        List<File> fileList2 = (List<File>) FileUtils.listFiles(dir2, extensions, false);
        FileDifference diff = new FileDifference(fileList1, fileList2);
        String[] addFilePaths = diff.getAddFilePaths();
        String[] delFileNames = diff.getDeleteFileNames();
        if (addFilePaths.length > 0) {
            ope.addEntry(addFilePaths, subDirName);
        }
        if (delFileNames.length > 0) {
            ope.deleteEntry(delFileNames, subDirName);
        }
        ope.end();
        return true;
    } catch (Exception e) {
        e.printStackTrace();
        ope.end();
        return false;
    }
}
Also used : GetConfig(massbank.GetConfig) List(java.util.List) File(java.io.File)

Example 9 with GetConfig

use of massbank.GetConfig in project MassBank-web by MassBank.

the class DisplayAll method init.

/**
 */
public void init() {
    setLayout(new BoxLayout(this.getContentPane(), BoxLayout.PAGE_AXIS));
    // �‹��ݒ�t�@�C������A�g�T�C�g��URL���擾
    String confPath = getCodeBase().toString();
    confPath = confPath.replaceAll("jsp/", "");
    GetConfig conf = new GetConfig(confPath);
    urlList = conf.getSiteUrl();
    serverUrl = conf.getServerUrl();
    baseUrl = serverUrl + "jsp/";
    // �s�[�N�����A�s�[�N���������̃p�����[�^�擾
    int paramMzNum = 0;
    if (getParameter("type") != null) {
        reqType = getParameter("type");
        if (reqType.equals("peak") || reqType.equals("diff")) {
            paramMzNum = Integer.parseInt(getParameter("pnum"));
            searchParam = "&num=" + paramMzNum;
            for (int i = 0; i < paramMzNum; i++) {
                String pnum = Integer.toString(i);
                String mz = getParameter("mz" + pnum);
                String tol = getParameter("tol" + pnum);
                String rInt = getParameter("int" + pnum);
                paramMz += mz + ",";
                paramTol += tol + ",";
                paramInt += rInt + ",";
                searchParam += "&mz" + pnum + "=" + mz;
                searchParam += "&tol" + pnum + "=" + tol;
                searchParam += "&int" + pnum + "=" + rInt;
            }
        }
    }
    numSpct = Integer.valueOf(getParameter("num"));
    plotPane = new PlotPane[numSpct];
    buttonPane = new ButtonPane[numSpct];
    clear();
    peaks1 = new Peak[numSpct];
    info = new RecordInfo[numSpct];
    cnt = new int[urlList.length];
    HashSet<String> compoundNameList = new HashSet();
    for (int i = 0; i < numSpct; i++) {
        // �p�����[�^�擾
        String pnum = Integer.toString(i + 1);
        int siteNo = Integer.parseInt(getParameter("site" + pnum));
        String id = getParameter("id" + pnum);
        String title = getParameter("name" + pnum);
        String formula = getParameter("formula" + pnum);
        String mass = getParameter("mass" + pnum);
        String ion = getParameter("ion" + pnum);
        int num = cnt[siteNo]++;
        info[i] = new RecordInfo(id, title, siteNo, num, formula, mass, ion);
        String[] items = title.split(";");
        compoundNameList.add(items[0]);
    }
    // �s�[�N�f�[�^�擾
    ArrayList resultList = getPeakData();
    // Molfile�f�[�^�擾
    Map<String, String> mapMolData = getMolData(compoundNameList);
    hitPeaks.mzInfoList = new ArrayList[numSpct];
    precursor = new String[numSpct];
    Vector<Vector<String>> mzAry = new Vector<Vector<String>>();
    for (int i = 0; i < numSpct; i++) {
        int siteNo = info[i].getSiteNo();
        int num = info[i].getNumber();
        ArrayList result = (ArrayList) resultList.get(siteNo);
        String line = (String) result.get(num);
        // �s�[�N�����A�s�[�N����������Ă΂ꂽ�ꍇ�A�q�b�g����m/z�l���Ԃ�̂Ŋi�[����
        String findStr = "hit=";
        int pos = line.indexOf(findStr);
        if (pos > 0) {
            String hit = line.substring(pos + 4);
            String[] hitMzInfo = hit.split("\t");
            boolean isDiff = false;
            // �s�[�N�����̏ꍇ
            if (reqType.equals("diff")) {
                isDiff = true;
            }
            // m/z�l���i�[
            ArrayList mzInfoList = hitPeaks.setMz(hitMzInfo, isDiff);
            hitPeaks.mzInfoList[i] = new ArrayList();
            hitPeaks.mzInfoList[i].addAll(mzInfoList);
            line = line.substring(0, pos);
        }
        // �v���J�[�T�[
        findStr = "precursor=";
        pos = line.indexOf(findStr);
        int posNext = 0;
        if (pos > 0) {
            posNext = line.indexOf("\t", pos);
            precursor[i] = line.substring(pos + findStr.length(), posNext);
            line = line.substring(0, pos);
        } else {
            precursor[i] = "";
        }
        String[] tmp = line.split("\t\t");
        Vector<String> mzs = new Vector<String>();
        // m/z�i�[
        for (int j = 0; j < tmp.length; j++) {
            mzs.add(tmp[j]);
        }
        mzAry.add(mzs);
    }
    for (int i = 0; i < numSpct; i++) {
        plotPane[i] = new PlotPane(i);
        plotPane[i].setPreferredSize(new Dimension(780, 200));
        plotPane[i].repaint();
        JPanel pane1 = new JPanel();
        String title = info[i].getTitle();
        String id = info[i].getID();
        String site = String.valueOf(info[i].getSiteNo());
        pane1.add(new NameButton(title, id, site));
        pane1.setLayout(new FlowLayout(FlowLayout.LEFT));
        pane1.setMaximumSize(new Dimension(pane1.getMaximumSize().width, 100));
        JPanel parentPane = new JPanel();
        JPanel childPane1 = new JPanel();
        JPanel childPane2 = new JPanel();
        childPane2.setBackground(Color.WHITE);
        childPane2.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
        childPane2.setMaximumSize(new Dimension(200, parentPane.getMaximumSize().height));
        childPane1.add(pane1);
        childPane1.add(plotPane[i]);
        buttonPane[i] = new ButtonPane(i);
        buttonPane[i].addDiffButton(plotPane[i].idPeak);
        buttonPane[i].setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
        buttonPane[i].setMaximumSize(new Dimension(buttonPane[i].getMaximumSize().width, 100));
        childPane1.add(buttonPane[i]);
        childPane1.setLayout(new BoxLayout(childPane1, BoxLayout.Y_AXIS));
        parentPane.add(childPane1);
        // ���p�l���E��: FORMULA��EXACT MASS��\��
        JLabel formuraLabel1 = new JLabel("    Formula: ");
        formuraLabel1.setOpaque(true);
        formuraLabel1.setBackground(Color.WHITE);
        formuraLabel1.setPreferredSize(new Dimension(84, 17));
        childPane2.add(formuraLabel1);
        JLabel formuraLabel2 = new JLabel(info[i].getFormula());
        formuraLabel2.setOpaque(true);
        formuraLabel2.setForeground(new Color(57, 127, 0));
        formuraLabel2.setBackground(Color.WHITE);
        formuraLabel2.setPreferredSize(new Dimension(116, 17));
        childPane2.add(formuraLabel2);
        JLabel emassLabel1 = new JLabel("    Exact Mass: ");
        emassLabel1.setOpaque(true);
        emassLabel1.setBackground(Color.WHITE);
        emassLabel1.setPreferredSize(new Dimension(84, 17));
        childPane2.add(emassLabel1);
        JLabel emassLabel2 = new JLabel();
        emassLabel2.setOpaque(true);
        emassLabel2.setForeground(new Color(57, 127, 0));
        emassLabel2.setBackground(Color.WHITE);
        emassLabel2.setPreferredSize(new Dimension(116, 17));
        String emass = info[i].getExactMass();
        if (!emass.equals("") && !emass.equals("0")) {
            emassLabel2.setText(emass);
        }
        childPane2.add(emassLabel2);
        // ���p�l���E��: Mol�\���\���p�l�����Z�b�g
        JPanel pane3 = null;
        String[] items = title.split(";");
        boolean isExist = false;
        String compoundName = items[0].toLowerCase();
        if (mapMolData.containsKey(compoundName)) {
            String moldata = mapMolData.get(compoundName);
            if (!moldata.equals("")) {
                pane3 = (MolViewPaneExt) new MolViewPaneExt(moldata, 200, this);
                isExist = true;
            }
        }
        if (!isExist) {
            // �f�[�^���擾�ł��Ȃ������ꍇ
            JLabel lbl = new JLabel("Not Available", JLabel.CENTER);
            lbl.setPreferredSize(new Dimension(180, 180));
            lbl.setBackground(new Color(0xF8, 0xF8, 0xFF));
            lbl.setBorder(new LineBorder(Color.BLACK, 1));
            lbl.setOpaque(true);
            GridBagLayout layout = new GridBagLayout();
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.insets = new Insets(1, 1, 1, 1);
            layout.setConstraints(lbl, gbc);
            pane3 = new JPanel();
            pane3.setPreferredSize(new Dimension(200, 200));
            pane3.setBackground(Color.WHITE);
            pane3.add(lbl);
        }
        childPane2.add(pane3);
        // ���p�l���E��: �\�����\�������̗]��
        JLabel lbl3 = new JLabel("");
        lbl3.setPreferredSize(new Dimension(200, 30));
        childPane2.add(lbl3);
        childPane2.setPreferredSize(new Dimension(200, 260));
        parentPane.add(childPane2);
        parentPane.setLayout(new BoxLayout(parentPane, BoxLayout.X_AXIS));
        add(parentPane);
        // �㉺�X�y�N�g���̋�؂�
        JPanel spacePane = new JPanel();
        spacePane.setPreferredSize(new Dimension(800, 2));
        spacePane.setBackground(Color.white);
        JLabel lbl4 = new JLabel("");
        lbl4.setPreferredSize(new Dimension(800, 2));
        spacePane.add(lbl4);
        add(spacePane);
        String ion = info[i].getIon();
        peaks1[i] = new Peak((Vector<String>) mzAry.get(i), emass, ion);
    }
    initMass();
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) FlowLayout(java.awt.FlowLayout) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) BoxLayout(javax.swing.BoxLayout) LineBorder(javax.swing.border.LineBorder) ArrayList(java.util.ArrayList) GetConfig(massbank.GetConfig) Vector(java.util.Vector) HashSet(java.util.HashSet) Color(java.awt.Color) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) Point(java.awt.Point)

Example 10 with GetConfig

use of massbank.GetConfig in project MassBank-web by MassBank.

the class SearchPage method init.

/**
 * ���C���v���O����
 */
public void init() {
    // �A�v���b�g�R���e�L�X�g�擾
    context = getAppletContext();
    // �A�v���b�g������ʃT�C�Y�擾
    initAppletWidth = getWidth();
    initAppletHight = getHeight();
    // �‹��ݒ�t�@�C������A�g�T�C�g��URL���擾
    String confPath = getCodeBase().toString();
    confPath = confPath.replaceAll("/jsp", "");
    GetConfig conf = new GetConfig(confPath);
    siteNameList = conf.getSiteName();
    baseUrl = conf.getServerUrl();
    // Cookie��񃆁[�e�B���e�B������
    cm = new CookieManager(this, "SerchApplet", 30, conf.isCookie());
    // Precursor m/z��񏉊���
    initPreInfo();
    // Tolerance��񏉊���
    initTolInfo();
    // Cutoff Threshold��񏉊���
    initCutoffInfo();
    // ���u��ʏ�񏉊���
    instInfo = new GetInstInfo(confPath);
    initInstInfo();
    // MS��ʏ�񏉊���
    initMsInfo();
    // �C�I����ʏ�񏉊���
    initIonInfo();
    // �E�C���h�E����
    createWindow();
    // �������_�C�A���O
    this.dlg = new ProgressDialog(getFrame());
    // ���[�U�[�t�@�C���Ǎ���
    if (getParameter("file") != null) {
        loadFile(getParameter("file"));
    } else // ����ʂ���̃N�G���lj�
    if (getParameter("num") != null) {
        DefaultTableModel dm = (DefaultTableModel) querySorter.getTableModel();
        dm.setRowCount(0);
        int num = Integer.parseInt(getParameter("num"));
        for (int i = 0; i < num; i++) {
            String pnum = Integer.toString(i + 1);
            String id = getParameter("qid" + pnum);
            String name = getParameter("name" + pnum);
            String site = getParameter("site" + pnum);
            String[] idNameSite = new String[] { id, name, site };
            nameList.add(idNameSite);
            site = siteNameList[Integer.parseInt(site)];
            String[] idNameSite2 = new String[] { id, name, site, String.valueOf(i + 1) };
            dm.addRow(idNameSite2);
        }
    }
}
Also used : GetConfig(massbank.GetConfig) GetInstInfo(massbank.GetInstInfo) DefaultTableModel(javax.swing.table.DefaultTableModel)

Aggregations

GetConfig (massbank.GetConfig)10 ArrayList (java.util.ArrayList)5 File (java.io.File)3 BorderLayout (java.awt.BorderLayout)2 Vector (java.util.Vector)2 JPanel (javax.swing.JPanel)2 Color (java.awt.Color)1 Dimension (java.awt.Dimension)1 FlowLayout (java.awt.FlowLayout)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 Point (java.awt.Point)1 HashSet (java.util.HashSet)1 List (java.util.List)1 BoxLayout (javax.swing.BoxLayout)1 JLabel (javax.swing.JLabel)1 ToolTipManager (javax.swing.ToolTipManager)1 Border (javax.swing.border.Border)1 EmptyBorder (javax.swing.border.EmptyBorder)1