Package org.brickred.socialauth

Examples of org.brickred.socialauth.Career


    } catch (Exception e) {
      throw new ServerDataException(
          "Failed to parse the career details from response."
              + PROFILE_URL, e);
    }
    Career career = null;
    if (root != null) {
      career = new Career();
      Education[] educationsArr = null;
      Position[] positionsArr = null;
      Recommendation[] recommendationsArr = null;
      String headline = XMLParseUtil.getElementData(root, "headline");
      career.setHeadline(headline);
      String id = XMLParseUtil.getElementData(root, "id");
      career.setId(id);
      // get educations
      NodeList educations = root.getElementsByTagName("education");
      if (educations != null && educations.getLength() > 0) {
        LOG.debug("Educations count " + educations.getLength());
        educationsArr = new Education[educations.getLength()];
        for (int i = 0; i < educations.getLength(); i++) {
          Education educationObj = new Education();
          Element educationEl = (Element) educations.item(i);
          String schoolName = XMLParseUtil.getElementData(
              educationEl, "school-name");
          if (schoolName != null) {
            educationObj.setSchoolName(schoolName);
          }
          String degree = XMLParseUtil.getElementData(educationEl,
              "degree");
          if (degree != null) {
            educationObj.setDegree(degree);
          }
          String fieldOfStudy = XMLParseUtil.getElementData(
              educationEl, "field-of-study");
          if (fieldOfStudy != null) {
            educationObj.setFieldOfStudy(fieldOfStudy);
          }
          NodeList sd = educationEl
              .getElementsByTagName("start-date");
          if (sd != null && sd.getLength() > 0) {
            String year = XMLParseUtil.getElementData(
                (Element) sd.item(0), "year");
            if (year != null) {
              DateComponents comp = new DateComponents();
              comp.setYear(Integer.parseInt(year));
              educationObj.setStartDate(comp);
            }

          }
          NodeList ed = educationEl.getElementsByTagName("end-date");
          if (ed != null && ed.getLength() > 0) {
            String year = XMLParseUtil.getElementData(
                (Element) ed.item(0), "year");
            if (year != null) {
              DateComponents comp = new DateComponents();
              comp.setYear(Integer.parseInt(year));
              educationObj.setEndDate(comp);
            }

          }
          educationsArr[i] = educationObj;
        }
      }

      // get positions
      NodeList positions = root.getElementsByTagName("position");
      if (positions != null && positions.getLength() > 0) {
        LOG.debug("Positions count " + positions.getLength());
        positionsArr = new Position[positions.getLength()];
        for (int i = 0; i < positions.getLength(); i++) {
          Position positionnObj = new Position();
          Element positionEl = (Element) positions.item(i);
          String pid = XMLParseUtil.getElementData(positionEl, "id");
          if (pid != null) {
            positionnObj.setPositionId(pid);
          }
          String title = XMLParseUtil.getElementData(positionEl,
              "title");
          if (title != null) {
            positionnObj.setTitle(title);
          }
          String isCurrent = XMLParseUtil.getElementData(positionEl,
              "is-current");
          if (isCurrent != null) {
            positionnObj.setCurrentCompany(Boolean
                .valueOf(isCurrent));
          }
          NodeList sd = positionEl.getElementsByTagName("start-date");
          if (sd != null && sd.getLength() > 0) {
            String year = XMLParseUtil.getElementData(
                (Element) sd.item(0), "year");
            if (year != null) {
              DateComponents comp = new DateComponents();
              comp.setYear(Integer.parseInt(year));
              positionnObj.setStartDate(comp);
            }

          }
          NodeList ed = positionEl.getElementsByTagName("end-date");
          if (ed != null && ed.getLength() > 0) {
            String year = XMLParseUtil.getElementData(
                (Element) ed.item(0), "year");
            if (year != null) {
              DateComponents comp = new DateComponents();
              comp.setYear(Integer.parseInt(year));
              positionnObj.setEndDate(comp);
            }

          }

          NodeList companyNodes = positionEl
              .getElementsByTagName("company");
          if (companyNodes != null && companyNodes.getLength() > 0) {
            Element company = (Element) companyNodes.item(0);
            String compid = XMLParseUtil.getElementData(company,
                "id");
            if (compid != null) {
              positionnObj.setCompanyId(compid);
            }
            String compName = XMLParseUtil.getElementData(company,
                "name");
            if (compName != null) {
              positionnObj.setCompanyName(compName);
            }
            String industry = XMLParseUtil.getElementData(company,
                "industry");
            if (industry != null) {
              positionnObj.setIndustry(industry);
            }
            String type = XMLParseUtil.getElementData(company,
                "type");
            if (type != null) {
              positionnObj.setCompanyType(type);
            }
          }
          positionsArr[i] = positionnObj;
        }
      }

      // getRecommendation
      NodeList recommendations = root
          .getElementsByTagName("recommendation");
      if (recommendations != null && recommendations.getLength() > 0) {
        LOG.debug("Recommendations count "
            + recommendations.getLength());
        recommendationsArr = new Recommendation[recommendations
            .getLength()];
        for (int i = 0; i < recommendations.getLength(); i++) {
          Recommendation recommendationObj = new Recommendation();
          Element recommendationEl = (Element) recommendations
              .item(i);
          String rid = XMLParseUtil.getElementData(recommendationEl,
              "id");
          if (rid != null) {
            recommendationObj.setRecommendationId(rid);
          }
          String text = XMLParseUtil.getElementData(recommendationEl,
              "recommendation-text");
          if (text != null) {
            recommendationObj.setRecommendationText(text);
          }

          String code = XMLParseUtil.getElementData(recommendationEl,
              "code");
          if (code != null) {
            recommendationObj.setRecommendationType(code);
          }

          NodeList recommenderNodes = recommendationEl
              .getElementsByTagName("recommender");
          if (recommenderNodes != null
              && recommenderNodes.getLength() > 0) {
            Element recommenderEl = (Element) recommenderNodes
                .item(0);
            String recommenderId = XMLParseUtil.getElementData(
                recommenderEl, "id");
            if (recommenderId != null) {
              recommendationObj.setRecommenderId(recommenderId);
            }
            String fname = XMLParseUtil.getElementData(
                recommenderEl, "first-name");
            if (fname != null) {
              recommendationObj.setRecommenderFirstName(fname);
            }
            String lname = XMLParseUtil.getElementData(
                recommenderEl, "last-name");
            if (lname != null) {
              recommendationObj.setRecommenderLastName(lname);
            }

          }
          recommendationsArr[i] = recommendationObj;
        }
      }

      if (educationsArr != null) {
        career.setEducations(educationsArr);
      }

      if (positionsArr != null) {
        career.setPositions(positionsArr);
      }

      if (recommendationsArr != null) {
        career.setRecommendations(recommendationsArr);
      }
    }
    return career;
  }
View Full Code Here


    } catch (Exception e) {
      throw new ServerDataException(
          "Failed to parse the career details from response."
              + PROFILE_URL, e);
    }
    Career career = null;
    if (root != null) {
      career = new Career();
      Education[] educationsArr = null;
      Position[] positionsArr = null;
      Recommendation[] recommendationsArr = null;
      String headline = XMLParseUtil.getElementData(root, "headline");
      career.setHeadline(headline);
      String id = XMLParseUtil.getElementData(root, "id");
      career.setId(id);
      // get educations
      NodeList educations = root.getElementsByTagName("education");
      if (educations != null && educations.getLength() > 0) {
        LOG.debug("Educations count " + educations.getLength());
        educationsArr = new Education[educations.getLength()];
        for (int i = 0; i < educations.getLength(); i++) {
          Education educationObj = new Education();
          Element educationEl = (Element) educations.item(i);
          String schoolName = XMLParseUtil.getElementData(
              educationEl, "school-name");
          if (schoolName != null) {
            educationObj.setSchoolName(schoolName);
          }
          String degree = XMLParseUtil.getElementData(educationEl,
              "degree");
          if (degree != null) {
            educationObj.setDegree(degree);
          }
          String fieldOfStudy = XMLParseUtil.getElementData(
              educationEl, "field-of-study");
          if (fieldOfStudy != null) {
            educationObj.setFieldOfStudy(fieldOfStudy);
          }
          NodeList sd = educationEl
              .getElementsByTagName("start-date");
          if (sd != null && sd.getLength() > 0) {
            String year = XMLParseUtil.getElementData(
                (Element) sd.item(0), "year");
            if (year != null) {
              DateComponents comp = new DateComponents();
              comp.setYear(Integer.parseInt(year));
              educationObj.setStartDate(comp);
            }

          }
          NodeList ed = educationEl.getElementsByTagName("end-date");
          if (ed != null && ed.getLength() > 0) {
            String year = XMLParseUtil.getElementData(
                (Element) ed.item(0), "year");
            if (year != null) {
              DateComponents comp = new DateComponents();
              comp.setYear(Integer.parseInt(year));
              educationObj.setEndDate(comp);
            }

          }
          educationsArr[i] = educationObj;
        }
      }

      // get positions
      NodeList positions = root.getElementsByTagName("position");
      if (positions != null && positions.getLength() > 0) {
        LOG.debug("Positions count " + positions.getLength());
        positionsArr = new Position[positions.getLength()];
        for (int i = 0; i < positions.getLength(); i++) {
          Position positionnObj = new Position();
          Element positionEl = (Element) positions.item(i);
          String pid = XMLParseUtil.getElementData(positionEl, "id");
          if (pid != null) {
            positionnObj.setPositionId(pid);
          }
          String title = XMLParseUtil.getElementData(positionEl,
              "title");
          if (title != null) {
            positionnObj.setTitle(title);
          }
          String isCurrent = XMLParseUtil.getElementData(positionEl,
              "is-current");
          if (isCurrent != null) {
            positionnObj.setCurrentCompany(Boolean
                .valueOf(isCurrent));
          }
          NodeList sd = positionEl.getElementsByTagName("start-date");
          if (sd != null && sd.getLength() > 0) {
            String year = XMLParseUtil.getElementData(
                (Element) sd.item(0), "year");
            if (year != null) {
              DateComponents comp = new DateComponents();
              comp.setYear(Integer.parseInt(year));
              positionnObj.setStartDate(comp);
            }

          }
          NodeList ed = positionEl.getElementsByTagName("end-date");
          if (ed != null && ed.getLength() > 0) {
            String year = XMLParseUtil.getElementData(
                (Element) ed.item(0), "year");
            if (year != null) {
              DateComponents comp = new DateComponents();
              comp.setYear(Integer.parseInt(year));
              positionnObj.setEndDate(comp);
            }

          }

          NodeList companyNodes = positionEl
              .getElementsByTagName("company");
          if (companyNodes != null && companyNodes.getLength() > 0) {
            Element company = (Element) companyNodes.item(0);
            String compid = XMLParseUtil.getElementData(company,
                "id");
            if (compid != null) {
              positionnObj.setCompanyId(compid);
            }
            String compName = XMLParseUtil.getElementData(company,
                "name");
            if (compName != null) {
              positionnObj.setCompanyName(compName);
            }
            String industry = XMLParseUtil.getElementData(company,
                "industry");
            if (industry != null) {
              positionnObj.setIndustry(industry);
            }
            String type = XMLParseUtil.getElementData(company,
                "type");
            if (type != null) {
              positionnObj.setCompanyType(type);
            }
          }
          positionsArr[i] = positionnObj;
        }
      }

      // getRecommendation
      NodeList recommendations = root
          .getElementsByTagName("recommendation");
      if (recommendations != null && recommendations.getLength() > 0) {
        LOG.debug("Recommendations count "
            + recommendations.getLength());
        recommendationsArr = new Recommendation[recommendations
            .getLength()];
        for (int i = 0; i < recommendations.getLength(); i++) {
          Recommendation recommendationObj = new Recommendation();
          Element recommendationEl = (Element) recommendations
              .item(i);
          String rid = XMLParseUtil.getElementData(recommendationEl,
              "id");
          if (rid != null) {
            recommendationObj.setRecommendationId(rid);
          }
          String text = XMLParseUtil.getElementData(recommendationEl,
              "recommendation-text");
          if (text != null) {
            recommendationObj.setRecommendationText(text);
          }

          String code = XMLParseUtil.getElementData(recommendationEl,
              "code");
          if (code != null) {
            recommendationObj.setRecommendationType(code);
          }

          NodeList recommenderNodes = recommendationEl
              .getElementsByTagName("recommender");
          if (recommenderNodes != null
              && recommenderNodes.getLength() > 0) {
            Element recommenderEl = (Element) recommenderNodes
                .item(0);
            String recommenderId = XMLParseUtil.getElementData(
                recommenderEl, "id");
            if (recommenderId != null) {
              recommendationObj.setRecommenderId(recommenderId);
            }
            String fname = XMLParseUtil.getElementData(
                recommenderEl, "first-name");
            if (fname != null) {
              recommendationObj.setRecommenderFirstName(fname);
            }
            String lname = XMLParseUtil.getElementData(
                recommenderEl, "last-name");
            if (lname != null) {
              recommendationObj.setRecommenderLastName(lname);
            }

          }
          recommendationsArr[i] = recommendationObj;
        }
      }

      if (educationsArr != null) {
        career.setEducations(educationsArr);
      }

      if (positionsArr != null) {
        career.setPositions(positionsArr);
      }

      if (recommendationsArr != null) {
        career.setRecommendations(recommendationsArr);
      }
    }
    return career;
  }
View Full Code Here

TOP

Related Classes of org.brickred.socialauth.Career

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.