Package gr.ekt.bte.core

Examples of gr.ekt.bte.core.StringValue


            return null;
        }
        List<Value> values = new ArrayList<Value>();
        for (String value : stringValues)
        {
            values.add(new StringValue(value));
        }
        return values;
    }
View Full Code Here


                converted_values.add(val.getAsString());
            }
            List<Value> final_value = new ArrayList<Value>();
            String v = StringUtils.join(converted_values.iterator(), separator
                    + (whitespaceAfter ? " " : ""));
            final_value.add(new StringValue(v));
            rec.updateField(field, final_value);
        }

        return rec;
    }
View Full Code Here

                    {
                        String valueString = value.getAsString();
                        if (StringUtils.isNotBlank(valueString)
                                && valueString.endsWith("."))
                        {
                            newValues.add(new StringValue(valueString
                                    .substring(0, valueString.length() - 1)));
                        }
                        else
                        {
                            newValues.add(new StringValue(valueString));
                        }
                    }

                    record.updateField(key, newValues);
                }
View Full Code Here

            {
                if (record.isMutable())
                {
                    record.makeMutable().addValue(
                            SubmissionLookupService.PROVIDER_NAME_FIELD,
                            new StringValue(providerName));
                }
            }
        }

        // Question: Do we want that in case of file data loader?
        // for each publication in the record set, if it has a DOI, try to find
        // extra pubs from the other providers
        if (searchTerms != null
                || (identifiers != null && !identifiers
                        .containsKey(SubmissionLookupDataLoader.DOI)))
        { // Extend
            Map<String, Set<String>> provider2foundDOIs = new HashMap<String, Set<String>>();
            List<String> foundDOIs = new ArrayList<String>();

            for (Record publication : recordSet.getRecords())
            {
                String providerName = SubmissionLookupUtils.getFirstValue(
                        publication,
                        SubmissionLookupService.PROVIDER_NAME_FIELD);

                String doi = null;

                if (publication.getValues(SubmissionLookupDataLoader.DOI) != null
                        && publication
                                .getValues(SubmissionLookupDataLoader.DOI)
                                .size() > 0)
                    doi = publication.getValues(SubmissionLookupDataLoader.DOI)
                            .iterator().next().getAsString();
                if (doi == null)
                {
                    doi = NOT_FOUND_DOI;
                }
                else
                {
                    doi = SubmissionLookupUtils.normalizeDOI(doi);
                    if (!foundDOIs.contains(doi))
                    {
                        foundDOIs.add(doi);
                    }
                    Set<String> tmp = provider2foundDOIs.get(providerName);
                    if (tmp == null)
                    {
                        tmp = new HashSet<String>();
                        provider2foundDOIs.put(providerName, tmp);
                    }
                    tmp.add(doi);
                }
            }

            for (String providerName : dataloadersMap.keySet())
            {
                DataLoader genProvider = dataloadersMap.get(providerName);

                if (!(genProvider instanceof SubmissionLookupDataLoader))
                {
                    continue;
                }

                SubmissionLookupDataLoader provider = (SubmissionLookupDataLoader) genProvider;

                // Provider must support DOI
                if (!provider.getSupportedIdentifiers().contains(
                        SubmissionLookupDataLoader.DOI))
                {
                    continue;
                }

                // if (evictProviders != null
                // && evictProviders.contains(provider.getShortName())) {
                // continue;
                // }
                Set<String> doiToSearch = new HashSet<String>();
                Set<String> alreadyFoundDOIs = provider2foundDOIs
                        .get(providerName);
                for (String doi : foundDOIs)
                {
                    if (alreadyFoundDOIs == null
                            || !alreadyFoundDOIs.contains(doi))
                    {
                        doiToSearch.add(doi);
                    }
                }
                List<Record> pPublications = null;
                Context context = null;
                try
                {
                    if (doiToSearch.size() > 0)
                    {
                        context = new Context();
                        pPublications = provider.getByDOIs(context, doiToSearch);
                    }
                }
                catch (Exception e)
                {
                    log.error(e.getMessage(), e);
                }
                finally {
                    if(context!=null && context.isValid()) {
                        context.abort();
                    }
                }
                if (pPublications != null)
                {
                    for (Record rec : pPublications)
                    {
                        recordSet.addRecord(rec);
                        if (rec.isMutable())
                        {
                            rec.makeMutable().addValue(
                                    SubmissionLookupService.PROVIDER_NAME_FIELD,
                                    new StringValue(providerName));
                        }
                    }
                  
                }
            }
View Full Code Here

            throw new RuntimeException(exMsg);
        }

        String doi = XMLUtils.getElementValue(dataRoot, "doi");
        if (doi != null)
            record.addValue("doi", new StringValue(doi));

        String itemType = doi != null ? XMLUtils.getElementAttribute(dataRoot,
                "doi", "type") : "unspecified";
        if (itemType != null)
            record.addValue("doiType", new StringValue(itemType));

        List<Element> identifier = XMLUtils.getElementList(dataRoot, "issn");
        for (Element ident : identifier)
        {
            if ("print".equalsIgnoreCase(ident.getAttribute("type"))
                    || StringUtils.isNotBlank(ident.getAttribute("type")))
            {
                String issn = ident.getTextContent().trim();
                if (issn != null)
                    record.addValue("printISSN", new StringValue(issn));
            }
            else
            {
                String eissn = ident.getTextContent().trim();
                if (eissn != null)
                    record.addValue("electronicISSN", new StringValue(eissn));
            }
        }
       
        List<Element> identifierisbn = XMLUtils.getElementList(dataRoot, "isbn");
        for (Element ident : identifierisbn)
        {
            if ("print".equalsIgnoreCase(ident.getAttribute("type"))
                    || StringUtils.isNotBlank(ident.getAttribute("type")))
            {
                String issn = ident.getTextContent().trim();
                if (issn != null)
                    record.addValue("printISBN", new StringValue(issn));
            }
            else
            {
                String eissn = ident.getTextContent().trim();
                if (eissn != null)
                    record.addValue("electronicISBN", new StringValue(eissn));
            }
        }

        String editionNumber = XMLUtils.getElementValue(dataRoot,
                "editionNumber");
        if (editionNumber != null)
            record.addValue("editionNumber", new StringValue(editionNumber));

        String volume = XMLUtils.getElementValue(dataRoot, "volume");
        if (volume != null)
            record.addValue("volume", new StringValue(volume));

        String issue = XMLUtils.getElementValue(dataRoot, "issue");
        if (issue != null)
            record.addValue("issue", new StringValue(issue));

        String year = XMLUtils.getElementValue(dataRoot, "year");
        if (year != null)
            record.addValue("year", new StringValue(year));

        String firstPage = XMLUtils.getElementValue(dataRoot, "first_page");
        if (firstPage != null)
            record.addValue("firstPage", new StringValue(firstPage));

        String lastPage = XMLUtils.getElementValue(dataRoot, "last_page");
        if (lastPage != null)
            record.addValue("lastPage", new StringValue(lastPage));

        String seriesTitle = XMLUtils.getElementValue(dataRoot, "series_title");
        if (seriesTitle != null)
            record.addValue("seriesTitle", new StringValue(seriesTitle));

        String journalTitle = XMLUtils.getElementValue(dataRoot,
                "journal_title");
        if (journalTitle != null)
            record.addValue("journalTitle", new StringValue(journalTitle));

        String volumeTitle = XMLUtils.getElementValue(dataRoot, "volume_title");
        if (volumeTitle != null)
            record.addValue("volumeTitle", new StringValue(volumeTitle));

        String articleTitle = XMLUtils.getElementValue(dataRoot,
                "article_title");
        if (articleTitle != null)
            record.addValue("articleTitle", new StringValue(articleTitle));

        String publicationType = XMLUtils.getElementValue(dataRoot,
                "pubblication_type");
        if (publicationType != null)
            record.addValue("publicationType", new StringValue(publicationType));

        List<String[]> authors = new LinkedList<String[]>();
        List<String[]> editors = new LinkedList<String[]>();
        List<String[]> translators = new LinkedList<String[]>();
        List<String[]> chairs = new LinkedList<String[]>();

        List<Element> contributors = XMLUtils.getElementList(dataRoot,
                "contributors");
        List<Element> contributor = null;
        if (contributors != null && contributors.size() > 0)
        {
            contributor = XMLUtils.getElementList(contributors.get(0),
                    "contributor");

            for (Element contrib : contributor)
            {

                String givenName = XMLUtils.getElementValue(contrib,
                        "given_name");
                String surname = XMLUtils.getElementValue(contrib, "surname");

                if ("editor".equalsIgnoreCase(contrib
                        .getAttribute("contributor_role")))
                {
                    editors.add(new String[] { givenName, surname });
                }
                else if ("chair".equalsIgnoreCase(contrib
                        .getAttribute("contributor_role")))
                {
                    chairs.add(new String[] { givenName, surname });
                }
                else if ("translator".equalsIgnoreCase(contrib
                        .getAttribute("contributor_role")))
                {
                    translators.add(new String[] { givenName, surname });
                }
                else
                {
                    authors.add(new String[] { givenName, surname });
                }
            }
        }

        if (authors.size() > 0)
        {
            List<Value> values = new LinkedList<Value>();
            for (String[] sArray : authors)
            {
                values.add(new StringValue(sArray[1] + ", " + sArray[0]));
            }
            record.addField("authors", values);
        }

        if (editors.size() > 0)
        {
            List<Value> values = new LinkedList<Value>();
            for (String[] sArray : editors)
            {
                values.add(new StringValue(sArray[1] + ", " + sArray[0]));
            }
            record.addField("editors", values);
        }

        if (translators.size() > 0)
        {
            List<Value> values = new LinkedList<Value>();
            for (String[] sArray : translators)
            {
                values.add(new StringValue(sArray[1] + ", " + sArray[0]));
            }
            record.addField("translators", values);
        }

        if (chairs.size() > 0)
        {
            List<Value> values = new LinkedList<Value>();
            for (String[] sArray : chairs)
            {
                values.add(new StringValue(sArray[1] + ", " + sArray[0]));
            }
            record.addField("chairs", values);
        }
        return record;
    }
View Full Code Here

    {
        MutableRecord record = new SubmissionLookupPublication("");

        String articleTitle = XMLUtils.getElementValue(dataRoot, "title");
        if (articleTitle != null)
            record.addValue("title", new StringValue(articleTitle));
        String summary = XMLUtils.getElementValue(dataRoot, "summary");
        if (summary != null)
            record.addValue("summary", new StringValue(summary));
        String year = XMLUtils.getElementValue(dataRoot, "published");
        if (year != null)
            record.addValue("published", new StringValue(year));
        String splashPageUrl = XMLUtils.getElementValue(dataRoot, "id");
        if (splashPageUrl != null)
            record.addValue("id", new StringValue(splashPageUrl));
        String comment = XMLUtils.getElementValue(dataRoot, "arxiv:comment");
        if (comment != null)
            record.addValue("comment", new StringValue(comment));

        List<Element> links = XMLUtils.getElementList(dataRoot, "link");
        if (links != null)
        {
            for (Element link : links)
            {
                if ("related".equals(link.getAttribute("rel"))
                        && "pdf".equals(link.getAttribute("title")))
                {
                    String pdfUrl = link.getAttribute("href");
                    if (pdfUrl != null)
                        record.addValue("pdfUrl", new StringValue(pdfUrl));
                }
            }
        }

        String doi = XMLUtils.getElementValue(dataRoot, "arxiv:doi");
        if (doi != null)
            record.addValue("doi", new StringValue(doi));
        String journalRef = XMLUtils.getElementValue(dataRoot,
                "arxiv:journal_ref");
        if (journalRef != null)
            record.addValue("journalRef", new StringValue(journalRef));

        List<String> primaryCategory = new LinkedList<String>();
        List<Element> primaryCategoryList = XMLUtils.getElementList(dataRoot,
                "arxiv:primary_category");
        if (primaryCategoryList != null)
        {
            for (Element primaryCategoryElement : primaryCategoryList)
            {
                primaryCategory
                        .add(primaryCategoryElement.getAttribute("term"));
            }
        }

        if (primaryCategory.size() > 0)
        {
            List<Value> values = new LinkedList<Value>();
            for (String s : primaryCategory)
            {
                values.add(new StringValue(s));
            }
            record.addField("primaryCategory", values);
        }

        List<String> category = new LinkedList<String>();
        List<Element> categoryList = XMLUtils.getElementList(dataRoot,
                "category");
        if (categoryList != null)
        {
            for (Element categoryElement : categoryList)
            {
                category.add(categoryElement.getAttribute("term"));
            }
        }

        if (category.size() > 0)
        {
            List<Value> values = new LinkedList<Value>();
            for (String s : category)
            {
                values.add(new StringValue(s));
            }
            record.addField("category", values);
        }

        List<String> authors = new LinkedList<String>();
        List<String> authorsWithAffiliations = new LinkedList<String>();
        List<Element> authorList = XMLUtils.getElementList(dataRoot, "author");
        if (authorList != null)
        {
            for (Element authorElement : authorList)
            {
              String authorName = XMLUtils.getElementValue(authorElement, "name");
              String authorAffiliation = XMLUtils.getElementValue(authorElement, "arxiv:affiliation");
             
              authors.add(authorName);
              authorsWithAffiliations.add(authorName +": " + authorAffiliation);
            }
        }

        if (authors.size() > 0)
        {
            List<Value> values = new LinkedList<Value>();
            for (String sArray : authors)
            {
                values.add(new StringValue(sArray));
            }
            record.addField("author", values);
        }
       
        if (authorsWithAffiliations.size() > 0)
        {
            List<Value> values = new LinkedList<Value>();
            for (String sArray : authorsWithAffiliations)
            {
                values.add(new StringValue(sArray));
            }
            record.addField("authorWithAffiliation", values);
        }

        return record;
View Full Code Here

        List<Value> new_values = new ArrayList<Value>();
        for (Value value : old_values)
        {
            String lang3 = value.getAsString();
            String lang2 = lang3.length() == 3 ? getLang2(lang3) : lang3;
            new_values.add(new StringValue(lang2));
        }

        rec.updateField("language", new_values);

        return rec;
View Full Code Here

                        }
                    }

                    if ("@@ident@@".equals(tmp))
                    {
                        newValues.add(new StringValue(stringValue));
                    }
                    else if (StringUtils.isNotBlank(tmp))
                    {
                        newValues.add(new StringValue(tmp));
                    }
                    else
                        newValues.add(new StringValue(stringValue));
                }

                record.updateField(key, newValues);
            }
        }
View Full Code Here

        Element description_en = list.get(1);     // English description
        // Element description3 = list.get(2);  // Authors information: NOT USE here

        String language = XMLUtils.getElementValue(description_ja, "dc:language");
        language = language != null ? language.toLowerCase() : "ja";
        record.addValue("language", new StringValue(language));

        if ("ja".equals(language) || "jpn".equals(language))
        {
            String title = XMLUtils.getElementValue(description_ja, "dc:title");
            if (title != null)
            {
                record.addValue("title", new StringValue(title));
            }
            String titleAlternative = XMLUtils.getElementValue(description_en, "dc:title");
            if (titleAlternative != null)
            {
                record.addValue("titleAlternative", new StringValue(titleAlternative));
            }

            List<Value> authors = getAuthors(description_ja);
            if (authors.size() > 0)
            {
                record.addField("authors", authors);
            }
            List<Value> authorAlternative = getAuthors(description_en);
            if (authorAlternative.size() > 0)
            {
                record.addField("auhtorAlternative", authorAlternative);
            }

            String publisher = XMLUtils.getElementValue(description_ja, "dc:publisher");
            if (publisher != null)
            {
                record.addValue("publisher", new StringValue(publisher));
            }
        }
        else
        {
            String title = XMLUtils.getElementValue(description_en, "dc:title");
            if (title != null)
            {
                record.addValue("title", new StringValue(title));
            }
            String titleAlternative = XMLUtils.getElementValue(description_ja, "dc:title");
            if (titleAlternative != null)
            {
                record.addValue("titleAlternative", new StringValue(titleAlternative));
            }

            List<Value> authors = getAuthors(description_en);
            if (authors.size() > 0)
            {
                record.addField("authors", authors);
            }
            List<Value> authorAlternative = getAuthors(description_ja);
            if (authorAlternative.size() > 0)
            {
                record.addField("authorAlternative", authorAlternative);
            }

            String publisher = XMLUtils.getElementValue(description_en, "dc:publisher");
            if (publisher != null)
            {
                record.addValue("publisher", new StringValue(publisher));
            }
        }

        String abstract_ja = XMLUtils.getElementValue(description_ja, "dc:description");
        String abstract_en = XMLUtils.getElementValue(description_en, "dc:description");
        if (abstract_ja != null && abstract_en != null)
        {
            List<Value> description = new LinkedList<Value>();
            description.add(new StringValue(abstract_ja));
            description.add(new StringValue(abstract_en));
            record.addField("description", description);
        }
        else if (abstract_ja != null)
        {
            record.addValue("description", new StringValue(abstract_ja));
        }
        else if (abstract_en != null)
        {
            record.addValue("description", new StringValue(abstract_en));
        }

        List<Value> subjects = getSubjects(description_ja);
        subjects.addAll(getSubjects(description_en));
        if (subjects.size() > 0)
        {
            record.addField("subjects", subjects);
        }

        String journal_j = XMLUtils.getElementValue(description_ja, "prism:publicationName");
        String journal_e = XMLUtils.getElementValue(description_en, "prism:publicationName");
        if (journal_j != null && journal_e != null)
        {
            record.addValue("journal", new StringValue(journal_j+" = "+journal_e));
        }
        else if (journal_j != null)
        {
           
            record.addValue("journal", new StringValue(journal_j));
        }
        else if (journal_e != null)
        {
           
            record.addValue("journal", new StringValue(journal_e));
        }

        String volume = XMLUtils.getElementValue(description_ja, "prism:volume");
        if (volume != null)
        {
            record.addValue("volume", new StringValue(volume));
        }

        String issue = XMLUtils.getElementValue(description_ja, "prism:number");
        if (issue != null)
        {
            record.addValue("issue", new StringValue(issue));
        }

        String spage = XMLUtils.getElementValue(description_ja, "prism:startingPage");
        if (spage != null)
        {
            record.addValue("spage", new StringValue(spage));
        }

        String epage = XMLUtils.getElementValue(description_ja, "prism:endingPage");
        if (epage != null)
        {
            record.addValue("epage", new StringValue(epage));
        }

        String pages = XMLUtils.getElementValue(description_ja, "prism:pageRange");
        if (pages != null && spage == null)
        {
            int pos = pages.indexOf("-");
            if (pos > -1)
            {
                spage = pages.substring(0, pos);
                epage = pages.substring(pos+1, pages.length() - pos);
                if (!epage.equals("") && spage.length() > epage.length())
                {
                    epage = spage.substring(0, spage.length() - epage.length()) + epage;
                }
            }
            else
            {
                spage = pages;
                epage = "";
            }
            record.addValue("spage", new StringValue(spage));
            if (!epage.equals("") && epage == null)
            {
                record.addValue("epage", new StringValue(epage));
            }
        }

        String issn = XMLUtils.getElementValue(description_ja, "prism:issn");
        if (issn != null)
        {
            record.addValue("issn", new StringValue(issn));
        }

        String issued = XMLUtils.getElementValue(description_ja, "prism:publicationDate");
        if (issued != null)
        {
            record.addValue("issued", new StringValue(issued));
        }

        String ncid = XMLUtils.getElementValue(description_ja, "cinii:ncid");
        if (ncid != null)
        {
            record.addValue("ncid", new StringValue(ncid));
        }

        String naid = XMLUtils.getElementValue(description_ja, "cinii:naid");
        if (naid != null)
        {
            record.addValue("naid", new StringValue(naid));
        }

        return record;
    }
View Full Code Here

            for (String author : authorList)
            {
                int pos = author.indexOf(" ");
                if (pos > -1)
                    author = author.substring(0, pos) + "," + author.substring(pos);
                authors.add(new StringValue(author));
            }
        }

        return authors;
    }
View Full Code Here

TOP

Related Classes of gr.ekt.bte.core.StringValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.