Example usage for org.springframework.util StringUtils isEmpty

List of usage examples for org.springframework.util StringUtils isEmpty

Introduction

In this page you can find the example usage for org.springframework.util StringUtils isEmpty.

Prototype

public static boolean isEmpty(@Nullable Object str) 

Source Link

Document

Check whether the given object (possibly a String ) is empty.

Usage

From source file:com.baidu.rigel.biplatform.tesseract.node.service.impl.IsNodeServiceImpl.java

@Override
public Node getNodeByCurrNode(Node node) {
    LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_BEGIN, "getNodeByCurrNode",
            "[node:" + node + "]"));
    if (node == null || StringUtils.isEmpty(node.getAddress()) || node.getPort() <= 0
            || StringUtils.isEmpty(node.getClusterName())) {
        LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_EXCEPTION, "getNodeByIpAndPort",
                "[node:" + node + "]"));
        throw new IllegalArgumentException();
    }// w ww.  ja v a  2 s.  c o  m
    List<Node> nodeList = this.getNodeListByClusterName(node.getClusterName());
    Node result = null;
    if (nodeList != null) {
        for (Node currNode : nodeList) {
            if (currNode.equals(node)) {
                result = currNode;
                break;
            }
        }
    }
    LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_END, "getNodeByIpAndPort",
            "[node:" + node + "]"));
    return result;
}

From source file:se.vgregion.usdservice.USDServiceImpl.java

@Override
public String createRequest(Properties requestParameters, String userId, Collection<Attachment> attachments) {
    int sessionID = 0;
    try {/* w  ww .  ja  v  a  2 s.c om*/
        sessionID = getUSDWebService().login(wsUser, wsPassword);

        String contactHandle = lookupContactHandle(userId, sessionID);
        if (contactHandle == null) {
            // Use the wsUser as fallback if the user is unknown
            contactHandle = lookupContactHandle(wsUser, sessionID);
        }

        requestParameters.setProperty("customer", contactHandle);

        List<String> lAttributes = new ArrayList<String>();
        List<String> lAttributeValues = new ArrayList<String>();

        for (Enumeration<Object> e = requestParameters.keys(); e.hasMoreElements();) {
            String key = (String) e.nextElement();
            lAttributes.add(key);
            lAttributeValues.add(key);
            lAttributeValues.add(requestParameters.getProperty(key));
        }

        List<String> properties = Collections.<String>emptyList();

        Holder<String> reqHandle = new Holder<String>("");
        Holder<String> reqNumber = new Holder<String>("");

        String template = "";

        Holder<String> result = new Holder<String>();
        getUSDWebService().createRequest(sessionID, contactHandle, toArrayOfString(lAttributeValues),
                toArrayOfString(properties), template, toArrayOfString(lAttributes), reqHandle, reqNumber,
                result);

        String handle = null;
        try {
            handle = extractHandle(result.toString());
        } catch (Exception e) {
            throw new RuntimeException("Error parsing handle to USD incident from xml response...\n" + result,
                    e);
        }

        if (!StringUtils.isEmpty(handle)) {
            for (Attachment attachment : attachments) {
                int i = 0;
                try {
                    createAttachment(sessionID, wsAttachmentRepHandle, handle, "Attachment " + i, attachment);
                } catch (Exception e) {
                    log.error("Failed to create attachment in USD [" + attachment.getFilename() + "]");
                }
                i++;
            }

        }

        return result.toString();
    } finally {
        getUSDWebService().logout(sessionID);
    }
}

From source file:com.github.hateoas.forms.spring.AffordanceBuilderFactory.java

@Override
public AffordanceBuilder linkTo(final Object invocationValue) {

    Assert.isInstanceOf(DummyInvocationUtils.LastInvocationAware.class, invocationValue);
    DummyInvocationUtils.LastInvocationAware invocations = (DummyInvocationUtils.LastInvocationAware) invocationValue;

    DummyInvocationUtils.MethodInvocation invocation = invocations.getLastInvocation();
    final Method invokedMethod = invocation.getMethod();
    MethodParameters parameters = new MethodParameters(invokedMethod);
    String pathMapping = MAPPING_DISCOVERER.getMapping(invokedMethod);

    Map<String, ActionInputParameter> requestParams = ActionDescriptorBuilder.getRequestParams(parameters,
            invocation.getArguments());/*  w  ww.j a  va2  s  .c  o  m*/
    Set<String> params = requestParams.keySet();
    String query = join(params);
    String mapping = StringUtils.isEmpty(query) ? pathMapping : pathMapping + "{?" + query + "}";

    PartialUriTemplate partialUriTemplate = new PartialUriTemplate(
            AffordanceBuilder.getBuilder().build().toString() + mapping);

    Iterator<Object> classMappingParameters = invocations.getObjectParameters();

    Map<String, Object> values = new HashMap<String, Object>();
    Iterator<String> names = partialUriTemplate.getVariableNames().iterator();
    while (classMappingParameters.hasNext()) {
        values.put(names.next(), classMappingParameters.next());
    }

    for (Object argument : invocation.getArguments()) {
        if (names.hasNext()) {
            values.put(names.next(), argument);
        }
    }

    ActionDescriptor actionDescriptor = ActionDescriptorBuilder.createActionDescriptor(parameters,
            invokedMethod, values, invocation.getArguments(), requestParams);
    if (paramsOnBody && !Affordance.isSafe(actionDescriptor.getHttpMethod())) {
        partialUriTemplate = new PartialUriTemplate(
                AffordanceBuilder.getBuilder().build().toString() + pathMapping);
    }
    return new AffordanceBuilder(partialUriTemplate.expand(values),
            Collections.singletonList(actionDescriptor));
}

From source file:com.ocs.dynamo.importer.impl.BaseXlsImporter.java

/**
 * Check if the specified row is completely empty
 * // w w  w. ja v a  2  s  . c  o m
 * @param row
 * @return
 */
public boolean isRowEmpty(Row row) {
    if (row == null || row.getFirstCellNum() < 0) {
        return true;
    }

    Iterator<Cell> iterator = row.iterator();
    while (iterator.hasNext()) {
        Cell next = iterator.next();
        String value = next.getStringCellValue();
        if (!StringUtils.isEmpty(value)) {
            return false;
        }
    }

    return true;
}

From source file:com.ocs.dynamo.ui.container.hierarchical.ModelBasedHierarchicalContainer.java

/**
 * Construct this hierarchical container using given root entity model and services.
 * //  w w w.ja  va 2s.com
 * @param messageService
 *            used for custom definitions, see class description.
 * @param rootEntityModel
 *            The top level entity model, the other sub models will be defined dynamically.
 * @param services
 *            All services to be used for each level.
 * @param joins
 *            Join information for each level.
 */
public HierarchicalContainer generateHierarchy(MessageService messageService,
        EntityModelFactory entityModelFactory, EntityModel<T> rootEntityModel, List<BaseService<?, ?>> services,
        HierarchicalFetchJoinInformation[] joins, QueryType queryType) {
    if (rootEntityModel != null) {
        // generate definitions
        EntityModel<?> pm = null;
        EntityModel<?> cm = rootEntityModel;
        for (int level = 0; level < services.size(); level++) {
            // Create container for hierarchy level
            Indexed container = createLevelContainer(level, services.get(level), cm, joins, queryType);

            // Initialize common properties
            List<String> propertyIds = new ArrayList<>();
            String msg = messageService.getEntityMessage(cm.getReference(), VISUAL_PROPERTY_IDS_MSG_KEY);
            if (!StringUtils.isEmpty(msg)) {
                // Use properties from message bundle
                String[] tokens = msg.split(",");
                if (level == 0) {
                    setContainerPropertyIds(Arrays.asList(tokens));
                }
                for (String prop : tokens) {
                    if ("null".equalsIgnoreCase(prop) || "".equals(prop)
                            || !container.getContainerPropertyIds().contains(prop)) {
                        propertyIds.add(null);
                    } else {
                        propertyIds.add(prop);
                    }
                }
            } else {
                // Create the common properties from the root
                for (AttributeModel am : cm.getAttributeModels()) {
                    if (am.isVisibleInTable()) {
                        propertyIds.add(am.getName());
                    }
                }
            }

            // Create definition
            if (level > 0) {
                // Find parent, look in message bundle and otherwise an
                // educated guess
                AttributeModel parent = findRelatedAttributeModel(messageService, cm, pm.getEntityClass(),
                        AttributeType.MASTER, "itemPropertyIdParent");
                // Must have a parent
                addDefinition(new ModelBasedHierarchicalDefinition(cm, container, level, parent.getName(),
                        propertyIds));
            } else {
                // Root will not have a parent
                addDefinition(new ModelBasedHierarchicalDefinition(cm, container, level, null, propertyIds));
            }

            if ((level + 1) < services.size()) {
                // Next child/level, look in message bundle and otherwise an
                // educated guess
                pm = cm;
                Class<?> pec = services.get(level + 1).getEntityClass();
                AttributeModel child = findRelatedAttributeModel(messageService, pm, pec, AttributeType.DETAIL,
                        "itemPropertyIdChild");
                if (child != null) {
                    cm = child.getNestedEntityModel();
                } else {
                    cm = entityModelFactory.getModel(pm.getReference() + "_" + pec.getSimpleName(), pec);
                }
            }
        }
    }
    return this;
}

From source file:cz.muni.fi.mir.tools.SiteTitleInterceptor.java

/**
 * Sets variable name under which is website title exposed in ModelAndView.
 * Default value is <b>websiteTitle</b>. If passed attributeName is null or
 * empty default one is used as well.//from   w w  w  . ja v a 2  s  .com
 *
 * @param modelAttributeName name of model variable
 */
public void setModelAttributeName(String modelAttributeName) {
    if (!StringUtils.isEmpty(modelAttributeName)) {
        this.modelAttributeName = modelAttributeName;
    }
}

From source file:com.sastix.cms.server.services.content.impl.CommonResourceServiceImpl.java

public AnalyzedZipResource analyzeZipFile(String context, String resourceURI, Resource zipResource) {
    byte[] insertedBytes;
    DataMaps modifiedDataMaps = null;/*  w w  w .  java  2 s.  c  o m*/
    List<ResourceDTO> resourceDTOList = new ArrayList<>();
    String startPage = null;
    String scormLandingPage = null;
    Resource parentResource = null;
    boolean isScormType = false;
    boolean isResourceWithStartPage = false;
    try {
        //get the zip bytes inserted
        insertedBytes = hashedDirectoryService.getBytesByURI(resourceURI, zipResource.getResourceTenantId());
        boolean isZipFile = zipFileHandlerService.isZipFile(insertedBytes);
        if (isZipFile) {
            //unzip it
            DataMaps dataMaps = zipFileHandlerService.unzip(insertedBytes);
            //is a scorm type
            isScormType = zipFileHandlerService.isScormType(dataMaps.getBytesMap());
            //is a cms resource with a startpage
            startPage = zipFileHandlerService.getResourceStartPage(dataMaps.getBytesMap());
            isResourceWithStartPage = !StringUtils.isEmpty(startPage);
            if (isScormType || isResourceWithStartPage) {
                /**
                 * Keep uid in a map for each resource found in zip
                 * uid: context (uuid of the zip) + filename
                 * eg
                 * 1429362943604-02f29f2a-f8df-4aaf-ad83-e2e65ffa1910-0-zaq12345/css/style.css
                 * */
                for (Map.Entry<String, byte[]> entry : dataMaps.getBytesMap().entrySet()) {
                    String filename = entry.getKey();

                    String thisResourceURI = context + filename;
                    //String extension = filename.substring(filename.lastIndexOf("."));
                    //String queryParams = filename.indexOf("?") > 0 ? "&" + filename.substring(filename.indexOf("?")) : "";
                    //String cpath = GET_DATA_DOMAIN + "?uid=" + uuid + extension + queryParams;
                    dataMaps.getUriMap().put(filename, thisResourceURI);
                    //dataMaps.getUidPathMap().put(filename, cpath);
                }

                /**
                 * Replace urls in resources
                 * */
                //modifiedDataMaps = zipFileHandlerService.replaceRelativePaths(dataMaps);
            }

            //find parent
            String parentFilename = zipFileHandlerService.findParentResource(dataMaps.getBytesMap());
            if (isResourceWithStartPage) {
                parentFilename = startPage;
            }

            //first insert the parent file
            String parentUri = dataMaps.getUriMap().get(parentFilename);
            byte[] parentData = dataMaps.getBytesMap().get(parentFilename);
            parentResource = insertResource(parentUri, parentData, parentFilename, zipResource.getAuthor(),
                    zipResource.getResourceTenantId(), zipResource);
            //                resourceDTOList.add(this.convertToDTO(parentResource));

            //insert exploded resources
            for (Map.Entry<String, byte[]> entry : dataMaps.getBytesMap().entrySet()) {
                String filename = entry.getKey();
                if (!filename.equals(parentFilename)) {//we do not want to add the parent file twice
                    String uid = dataMaps.getUriMap().get(filename);
                    byte[] data = entry.getValue();
                    byte[] modifiedData = dataMaps.getBytesMap().get(filename);
                    //check if it is modified
                    if (modifiedData != null) {
                        data = modifiedData;
                    }

                    //insert
                    Resource resourceDTO = insertResource(uid, data, filename, zipResource.getAuthor(),
                            zipResource.getResourceTenantId(), parentResource);
                    resourceDTOList.add(this.convertToDTO(resourceDTO));
                }
            }

        }
    } catch (IOException e) {
        throw new ResourceAccessError(e.toString());
    }

    AnalyzedZipResource analyzedZipResource = new AnalyzedZipResource(
            resourceDTOList.isEmpty() ? null : resourceDTOList, startPage);
    analyzedZipResource.setParentID(parentResource != null ? parentResource.getId() : null);
    return analyzedZipResource;
}

From source file:com.web.mavenproject6.controller.UserController.java

@RequestMapping(value = "/profile/update", method = RequestMethod.POST)
@ResponseBody//from  w  ww .  j  a v a2s . co  m
public String userProfileUpdate(@RequestParam("sdata") String sdata) throws JSONException {

    if (StringUtils.isEmpty(sdata)) {
        return (new Date()).toString();
    }

    JSONObject o = new JSONObject(sdata);
    Object pObject = personalService.findByAccessNumber((String) o.get("propId"));
    if (pObject instanceof personal) {
        personal p = (personal) pObject;
        p.setFname((String) o.get("fname"));
        p.setSname((String) o.get("sname"));
        p.setTname((String) o.get("tname"));
        p.setPassportNum("-");
        p.setPassportSeria((String) o.get("pasport"));
        p.setAddres((String) o.get("address"));
        p.setInfo((String) o.get("comment"));
        p.setPhone((String) o.get("phone"));
        p.setStage((String) o.get("stage"));
        p.setOffice((String) o.get("office"));
        p.setPost((String) o.get("post"));
        p.setLastUpdate(new Date());
        personalService.getRepository().save(p);
        return p.getLastUpdate().toString();
    }

    Object gObject = guestService.findByAccessNumber((String) o.get("propId"));
    if (gObject instanceof guest) {
        guest g = (guest) gObject;
        g.setFname((String) o.get("fname"));
        g.setSname((String) o.get("sname"));
        g.setTname((String) o.get("tname"));
        g.setPassportNum("-");
        g.setPassportSeria((String) o.get("pasport"));
        g.getPersonal_guest().setLastUpdate(new Date());
        guestService.getRepository().save(g);
        return g.getPersonal_guest().getLastUpdate().toString();
    }
    return (new Date()).toString();
}

From source file:co.adun.mvnejb3jpa.web.controller.InitiateLeadController.java

private List<LtLead> process(LeadModel model) throws BusinessException {

    List<LtLeadModel> ltLeadsModel = model.getLtLeadsModel();
    List<LtLead> ltLeads = new ArrayList<LtLead>();
    LtUser user = userService.getCurrentUser(WebSecurityContext.getUsername());

    DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy", Locale.ENGLISH);

    for (LtLeadModel ltLeadModel : ltLeadsModel) {
        LtLead ltLead = ltLeadModel.getLtLead();

        if (ltLead != null && !StringUtils.isEmpty(ltLeadModel.getFormId())) {

            DateValueModel birthDateModel = ltLeadModel.getBirthDateModel();
            if (!StringUtils.isEmpty(birthDateModel.getValue())) {
                Date date = null;
                try {
                    date = dateFormat.parse(birthDateModel.getValue());
                } catch (ParseException e) {
                    logger.info(e.getMessage());
                }//from   w  ww.j av  a2s  .  c  om
                ltLead.getLtSubject().setBirthDate(date);
            }

            DateValueModel entryDateModel = ltLeadModel.getEntryDateModel();
            if (!StringUtils.isEmpty(entryDateModel.getValue())) {
                Date date = null;
                try {
                    date = dateFormat.parse(entryDateModel.getValue());
                } catch (ParseException e) {
                    logger.info(e.getMessage());
                }
                ltLead.getLtSubject().setEntryDate(date);
            }

            MissionCode missionCode = ltLead.getMissionCode();

            // if Mission Box is selected by not Supervisor and Analyst,
            // assign
            // Lead to mission box
            boolean assignToSup = false;
            boolean assignToAna = false;
            logger.info("Calling leadService.save");

            /*
             * If the Analyst is selected, the lead is assigned to the
             * analyst. If analyst is not selected and Supervisor is
             * selected, then the lead is assigned to the Supervisor
             */

            // assign to supervisor, if it is selected

            ValueModel analystModel = ltLeadModel.getAnalystModel();
            if (!StringUtils.isEmpty(analystModel.getValue())) {
                LtUser ltUserByLtAssignToUserId = new LtUser();
                ltUserByLtAssignToUserId.setId(new Long(analystModel.getValue()));
                ltLead.setLtUserByLtAssignToUserId(ltUserByLtAssignToUserId);
                assignToAna = true;
            }

            ValueModel supervisorModel = ltLeadModel.getSupervisorModel();
            logger.info("Supervisor model value=" + supervisorModel.getValue());
            if (!assignToAna) {
                if (!StringUtils.isEmpty(supervisorModel.getValue())) {
                    LtUser ltUserByLtAssignToUserId = new LtUser();
                    ltUserByLtAssignToUserId.setId(new Long(supervisorModel.getValue()));
                    ltLead.setLtUserByLtAssignToUserId(ltUserByLtAssignToUserId);
                    assignToSup = true;
                }
            }

            StatusCode statusCode = new StatusCode();
            if (!assignToSup && !assignToAna) {
                // TODO refactor to Constants
                if (missionCode != null) {
                    setMissionCodeToLead(missionCode, ltLead);
                } else {
                    ltLead.setMissionCode(null);
                }
                // set Lead to unassigned status, when it is not assigned to
                // a
                // person
                statusCode.setId(100L); // Unassigned cod
            }

            // Lead is in assigned status, when is is assigned to a person
            if (assignToSup == true || assignToAna == true) {
                statusCode.setId(101L); // assigned code
                ltLead.setMissionCode(null);
            }

            ltLead.setStatusCode(statusCode);

            LeadGeneratedFromCode leadGeneratedFromCode = ltLead.getLeadGeneratedFromCode();
            String abbreviation = leadGeneratedFromCode.getAbbreviation();
            if (!StringUtils.isEmpty(abbreviation) && !"Select...".equals(abbreviation)) {
                String[] strings = StringUtils.split(abbreviation, ":");
                if (strings != null) {
                    leadGeneratedFromCode.setId(new Long(strings[0]));
                    leadGeneratedFromCode.setAbbreviation(strings[1]);
                }
            }

            LeadTypeCode leadTypeCode = ltLead.getLeadTypeCode();
            abbreviation = leadTypeCode.getAbbreviation();
            if (!StringUtils.isEmpty(abbreviation) && !"Select...".equals(abbreviation)) {
                String[] strings = StringUtils.split(abbreviation, ":");
                if (strings != null) {
                    leadTypeCode.setId(new Long(strings[0]));
                    leadTypeCode.setAbbreviation(strings[1]);
                }
            }

            Set<LtLeadSource> ltLeadSources = new HashSet<LtLeadSource>();
            LtLeadSource ltLeadSource = ltLeadModel.getLtLeadSource();
            ContactTypeCode contactTypeCode = ltLeadSource.getContactTypeCode();
            abbreviation = contactTypeCode.getAbbreviation();
            if (!StringUtils.isEmpty(abbreviation) && !"Select...".equals(abbreviation)) {
                String[] strings = StringUtils.split(abbreviation, ":");
                if (strings != null) {
                    contactTypeCode.setId(new Long(strings[0]));
                    contactTypeCode.setAbbreviation(strings[1]);
                    ltLeadSource.setLtLead(ltLead);
                    ltLeadSources.add(ltLeadSource);
                }
            }
            ltLead.setLtLeadSources(ltLeadSources);

            Set<LtLeadComment> ltLeadComments = new HashSet<LtLeadComment>();
            LtLeadComment ltLeadComment = ltLeadModel.getLtLeadComment();
            if (ltLeadComment != null && !StringUtils.isEmpty(ltLeadComment.getLeadComment())) {
                ltLeadComments.add(ltLeadComment);
            }
            ltLead.setLtLeadComments(ltLeadComments);

            ClassAdmissionCode classAdmissionCode = ltLead.getLtSubject().getClassAdmissionCode();
            abbreviation = classAdmissionCode.getAbbreviation();
            if (!StringUtils.isEmpty(abbreviation) && !"Select...".equals(abbreviation)) {
                String[] strings = StringUtils.split(abbreviation, ":");
                if (strings != null) {
                    classAdmissionCode.setId(new Long(strings[0]));
                    classAdmissionCode.setAbbreviation(strings[1]);
                } else {
                    ltLead.getLtSubject().setClassAdmissionCode(null);
                }
            } else {
                ltLead.getLtSubject().setClassAdmissionCode(null);
            }

            CountryCode countryCode = ltLead.getLtSubject().getCountryCode();
            abbreviation = countryCode.getAbbreviation();
            if (!StringUtils.isEmpty(abbreviation) && !"Select...".equals(abbreviation)) {
                String[] strings = StringUtils.split(abbreviation, ":");
                if (strings != null) {
                    countryCode.setId(new Long(strings[0]));
                    countryCode.setAbbreviation(strings[1]);
                } else {
                    ltLead.getLtSubject().setCountryCode(null);
                }
            } else {
                ltLead.getLtSubject().setCountryCode(null);
            }

            GenderCode genderCode = ltLead.getLtSubject().getGenderCode();
            abbreviation = genderCode.getAbbreviation();
            if (!StringUtils.isEmpty(abbreviation) && !"Select...".equals(abbreviation)) {
                String[] strings = StringUtils.split(abbreviation, ":");
                if (strings != null) {
                    genderCode.setId(new Long(strings[0]));
                    genderCode.setAbbreviation(strings[1]);
                } else {
                    ltLead.getLtSubject().setGenderCode(null);
                }
            } else {
                ltLead.getLtSubject().setGenderCode(null);
            }

            Set<LtLeadSpecialProject> ltLeadSpecialProjects = new HashSet<LtLeadSpecialProject>();
            for (LtLeadSpecialProject ltLeadSpecialProject : ltLeadModel.getLtLeadSpecialProjects()) {
                SpecialProjectCode specialProjectCode = ltLeadSpecialProject.getSpecialProjectCode();
                abbreviation = specialProjectCode.getAbbreviation();
                if (!StringUtils.isEmpty(abbreviation) && !"Select...".equals(abbreviation)) {
                    String[] strings = StringUtils.split(abbreviation, ":");
                    if (strings != null) {
                        specialProjectCode.setId(new Long(strings[0]));
                        specialProjectCode.setAbbreviation(strings[1]);
                        ltLeadSpecialProject.setLtLead(ltLead);
                        ltLeadSpecialProjects.add(ltLeadSpecialProject);
                    }
                }
            }
            ltLead.setLtLeadSpecialProjects(ltLeadSpecialProjects);

            Set<LtSubjectCitizenshipCountry> ltSubjectCitizenshipCountries = new HashSet<LtSubjectCitizenshipCountry>();
            for (LtSubjectCitizenshipCountry ltSubjectCitizenshipCountry : ltLeadModel
                    .getLtSubjectCitizenshipCountries()) {
                CountryCode cocCountryCode = ltSubjectCitizenshipCountry.getCountryCode();
                abbreviation = cocCountryCode.getAbbreviation();
                if (!StringUtils.isEmpty(abbreviation) && !"Select...".equals(abbreviation)) {
                    String[] strings = StringUtils.split(abbreviation, ":");
                    if (strings != null) {
                        cocCountryCode.setId(new Long(strings[0]));
                        cocCountryCode.setAbbreviation(strings[1]);
                        ltSubjectCitizenshipCountry.setLtSubject(ltLead.getLtSubject());
                        ltSubjectCitizenshipCountries.add(ltSubjectCitizenshipCountry);
                    }
                }
            }
            ltLead.getLtSubject().setLtSubjectCitizenshipCountries(ltSubjectCitizenshipCountries);

            Set<LtAssociatedLead> ltAssociatedLeads = new HashSet<LtAssociatedLead>();
            Set<LtAssociatedSubject> ltAssociatedSubjects = new HashSet<LtAssociatedSubject>();
            List<AssociatedLeadModel> associates = ltLeadModel.getAssociateModel();
            for (AssociatedLeadModel associateModel : associates) {
                String id = associateModel.getValue();
                if (!StringUtils.isEmpty(id)) {

                    RelationshipCode code = associateModel.getRelationshipCode();
                    code.setId(PageModelUtils.getCode(code.getAbbreviation()));

                    LtSubject ltAssociate = ltLeadsModel.get(Integer.parseInt(id)).getLtLead().getLtSubject();
                    LtAssociatedSubject ltAssociatedSubject = new LtAssociatedSubject();
                    ltAssociatedSubject.setLtSubject(ltLead.getLtSubject());
                    ltAssociatedSubject.setLtSubjectAssociate(ltAssociate);
                    ltAssociatedSubject.setRelationshipCode(code);
                    ltAssociatedSubjects.add(ltAssociatedSubject);

                    LtLead ltAssociateLead = ltLeadsModel.get(Integer.parseInt(id)).getLtLead();
                    LtAssociatedLead ltAssociatedLead = new LtAssociatedLead();
                    ltAssociatedLead.setLtLeadByLtLeadId(ltLead);
                    ltAssociatedLead.setLtLeadByLtAssociatedLeadId(ltAssociateLead);
                    ltAssociatedLeads.add(ltAssociatedLead);
                }
            }
            ltLead.setLtAssociatedLeadsForLtLeadId(ltAssociatedLeads);
            ltLead.getLtSubject().setLtAssociatedSubjects(ltAssociatedSubjects);

            Set<LtLeadSubject> ltLeadSubjects = new HashSet<LtLeadSubject>();
            LtLeadSubject ltLeadSubject = ltLeadModel.getLtLeadSubject();
            ltLeadSubject.setLtLead(ltLead);
            ltLeadSubject.setLtSubject(ltLead.getLtSubject());
            ltLeadSubjects.add(ltLeadSubject);
            ltLead.setLtLeadSubjects(ltLeadSubjects);

            ltLead.setLtUserByCreateBy(user);
            ltLead.setLtUserByModifiedBy(user);

            ltLeads.add(ltLead);
        }
    }

    return ltLeads;
}

From source file:org.ihtsdo.otf.snomed.service.ConceptLookUpServiceImpl.java

/**returns referenceComponentDescription for given referenceComponentId
 * @param referenceComponentId/*ww w  .ja v a2s  . co  m*/
 * @return
 * @throws RefsetGraphAccessException
 */
@Override
@Cacheable(value = { "referenceComponentDescription" })
public String getMemberDescription(String referenceComponentId) throws RefsetGraphAccessException {

    LOGGER.debug("getting member description for {} ", referenceComponentId);

    String label = "";

    if (StringUtils.isEmpty(referenceComponentId)) {

        return label;
    }

    TitanGraph g = null;
    try {

        g = factory.getReadOnlyGraph();

        Iterable<Result<Vertex>> vs = g.indexQuery("concept", "v.sctid:" + referenceComponentId).vertices();
        for (Result<Vertex> r : vs) {

            Vertex v = r.getElement();

            label = v.getProperty(Properties.title.toString());
            break;

        }

        RefsetGraphFactory.commit(g);

    } catch (Exception e) {

        RefsetGraphFactory.rollback(g);

        LOGGER.error("Error duing concept details fetch", e);

        throw new RefsetGraphAccessException(e.getMessage(), e);

    } finally {

        RefsetGraphFactory.shutdown(g);

    }

    return label;
}