Example usage for org.apache.commons.lang StringUtils substringBeforeLast

List of usage examples for org.apache.commons.lang StringUtils substringBeforeLast

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils substringBeforeLast.

Prototype

public static String substringBeforeLast(String str, String separator) 

Source Link

Document

Gets the substring before the last occurrence of a separator.

Usage

From source file:MstrKasMasuk.Entry.java

private void Search() {
    try {/*from  w w w  .j  a  v  a  2s  .co  m*/
        MstrKasMasuk x = new MstrKasMasuk();
        x.Search(_ID);
        if (x._Akses.equals("-")) {
            txt_id.setText(x.id);
            String tgl = StringUtils.substringBeforeLast(x.tgl, " ");
            txt_tgl_masuk.setDate(java.sql.Date.valueOf(tgl));
            txt_ket.setText(x.ket);
            txt_jum.setText(x.jum_uang);
            txt_id.setEditable(false);
        }
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(null, ex);
    }
}

From source file:MstrKasKeluar.Entry.java

private void Search() {
    try {/* www  .j  a  va  2s  .  c om*/
        MstrKasKeluar x = new MstrKasKeluar();
        x.Search(_ID);
        if (x._Akses.equals("-")) {
            txt_id.setText(x.id);
            String tgl = StringUtils.substringBeforeLast(x.tgl, " ");
            txt_tgl_keluar.setDate(java.sql.Date.valueOf(tgl));
            txt_ket.setText(x.ket);
            txt_jum.setText(x.jum_uang);

            txt_id.setEditable(false);
        }
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(null, ex);
    }
}

From source file:eionet.cr.web.action.VoIDActionBean.java

/**
 * Handles the request for viewing VoID.
 *
 * @return//from  ww w .  ja  v a  2 s .c o  m
 */
@DefaultHandler
public Resolution getVoID() {
    contextRoot = StringUtils.substringBeforeLast(getContext().getRequest().getRequestURL().toString(), "/");

    StreamingResolution result = new StreamingResolution("application/xml") {
        public void stream(HttpServletResponse response) throws Exception {
            List<UploadDTO> uploads = DAOFactory.get().getDao(HelperDAO.class).getAllRdfUploads();
            VoIDXmlWriter xmlWriter = new VoIDXmlWriter(response.getOutputStream(), contextRoot);
            xmlWriter.writeVoIDXml(uploads);
        }
    };
    return result;
}

From source file:eionet.web.action.SchemasRdfActionBean.java

/**
 * Handles the request for viewing VoID.
 *
 * @return//  ww  w. j  a v  a  2  s.c  om
 */
@DefaultHandler
public Resolution getRdf() {
    contextRoot = StringUtils.substringBeforeLast(getContext().getRequest().getRequestURL().toString(), "/");

    StreamingResolution result = new StreamingResolution("application/xml") {
        public void stream(HttpServletResponse response) throws Exception {
            SchemasManifestXmlWriter xmlWriter = new SchemasManifestXmlWriter(response.getOutputStream(),
                    contextRoot, schemaService);
            xmlWriter.writeManifestXml();
        }
    };
    return result;
}

From source file:eionet.cr.harvest.util.CsvImportUtil.java

/**
 * Harvests CSV/TSV file.//from  w ww  .  ja v  a  2s .  co m
 *
 * @param subject Subject data object of file location.
 * @param uri file (Source/Graph) uri
 * @param userName user who executed the harvest
 * @return List of warning messages recieved from upload and post harvest scripts
 * @throws Exception if harvest fails
 */
public static List<String> harvestTableFile(SubjectDTO subject, String uri, String userName) throws Exception {

    List<String> warningMessages = new ArrayList<String>();

    String fileUri = uri;
    String fileLabel = subject.getObjectValue(Predicates.RDFS_LABEL);
    FileType fileType = FileType.valueOf(subject.getObjectValue(Predicates.CR_MEDIA_TYPE));
    String objectsType = subject.getObjectValue(Predicates.CR_OBJECTS_TYPE);
    String publisher = subject.getObjectValue(Predicates.DCTERMS_PUBLISHER);
    String license = subject.getObjectValue(Predicates.DCTERMS_RIGHTS);
    String attribution = subject.getObjectValue(Predicates.DCTERMS_BIBLIOGRAPHIC_CITATION);
    String source = subject.getObjectValue(Predicates.DCTERMS_SOURCE);
    long fileSize = Long.parseLong(subject.getObjectValue(Predicates.CR_BYTE_SIZE));
    Collection<String> uniqueColumns = subject.getObjectValues(Predicates.CR_OBJECTS_UNIQUE_COLUMN);

    String folderUri = StringUtils.substringBeforeLast(uri, "/");
    String relativeFilePath = FolderUtil.extractPathInUserHome(fileUri);

    // Clear graph
    DAOFactory.get().getDao(HarvestSourceDAO.class).removeHarvestSources(Collections.singletonList(uri));

    CsvImportHelper helper = new CsvImportHelper(new ArrayList<String>(uniqueColumns), fileUri, fileLabel,
            fileType, objectsType, publisher, license, attribution, source);

    // Store file as new source, but don't harvest it
    helper.insertFileMetadataAndSource(fileSize, userName);

    // Add metadata about user folder update
    helper.linkFileToFolder(folderUri, userName);

    // Parse and insert triples from file to triplestore
    CSVReader csvReader = helper.createCSVReader(folderUri, relativeFilePath, userName, true);

    try {
        csvReader = helper.createCSVReader(folderUri, relativeFilePath, userName, true);
        helper.extractObjects(csvReader);
        helper.saveWizardInputs();

        // Run data linking scripts
        try {
            List<String> warnings = helper.runScripts();
            if (warnings.size() > 0) {
                for (String w : warnings) {
                    warningMessages.add(w);
                }
            }
        } catch (Exception e) {
            LOGGER.error("Failed to run data linking scripts", e);
            warningMessages.add("Failed to run data linking scripts: " + e.getMessage());
        }
    } catch (Exception e) {
        LOGGER.error("Exception while reading uploaded file", e);
        warningMessages.add("Exception while reading uploaded file: " + e.getMessage());
    } finally {
        CsvImportHelper.close(csvReader);
    }

    return warningMessages;
}

From source file:com.alibaba.stonelab.toolkit.autoconf.Autoconf.java

private void init(List<String> files) {
    for (String file : files) {
        String f = StringUtils.replace(file, "\\", "/");
        String base = StringUtils.substringBeforeLast(file, "/");

        try {/*from  ww w .  j  a  v  a 2s .co  m*/
            parser(base, f);
        } catch (Exception e) {
            throw new AutoconfException("Parser error.");
        }
    }

}

From source file:info.magnolia.importexport.BootstrapFilesComparator.java

private static String getExtension(File file) {
    String ext = StringUtils.substringAfterLast(file.getName(), ".");
    if (("." + ext).equals(DataTransporter.GZ) || ("." + ext).equals(DataTransporter.ZIP)) {
        ext = StringUtils.substringAfterLast(StringUtils.substringBeforeLast(file.getName(), "."), ".");
    }/* w w  w  .j  a  v a  2s  .c  om*/
    return ext;
}

From source file:ips1ap101.lib.base.BaseBundle.java

public static String getOpcionOrdenFuncionExport(String key) {
    String string = getString(key, OPCION_ORDEN_FUNCION_EXPORT);
    if (string == null) {
        String dominio = StringUtils.substringBeforeLast(key, ".");
        if (key.equals(dominio)) {
        } else {/*from  ww  w.jav a 2  s .com*/
            string = getString(dominio, OPCION_ORDEN_FUNCION_EXPORT);
        }
    }
    if (string == null) {
        string = getString(DEFAULT, OPCION_ORDEN_FUNCION_EXPORT);
    }
    return string;
}

From source file:eu.annocultor.converters.europeana.EuropeanaSolrDocumentTagger.java

String makeRecordHash(String resolveUri) {
    if (resolveUri.contains("/")) {
        resolveUri = StringUtils.substringAfterLast(resolveUri, "/");
    }/*from w  w  w .  java 2s  . c  o m*/
    return StringUtils.substringBeforeLast(resolveUri, ".");
}

From source file:eionet.web.action.VoIDActionBean.java

/**
 * Handles the request for viewing VoID.
 *
 * @return//from  ww  w  .  j  a  v  a 2  s.co  m
 */
@DefaultHandler
public Resolution getVoID() {
    contextRoot = StringUtils.substringBeforeLast(getContext().getRequest().getRequestURL().toString(), "/");

    StreamingResolution result = new StreamingResolution("application/xml") {
        public void stream(HttpServletResponse response) throws Exception {
            List<DataElement> dataElements = dataService.getDataElementsWithFixedValues();

            HashSet<String> datasetStatuses = new HashSet<String>();
            datasetStatuses.add("Released");
            datasetStatuses.add("Recorded");
            DDSearchEngine searchEngine = new DDSearchEngine(ConnectionUtil.getConnection());
            Vector tables = searchEngine.getDatasetTables(null, null, null, null, null, null, datasetStatuses,
                    false);

            VoIDXmlWriter xmlWriter = new VoIDXmlWriter(response.getOutputStream(), contextRoot);
            xmlWriter.writeVoIDXml(dataElements, tables);
        }
    };
    return result;
}