private static Authorship createAuthorship(Map<String, String> beanAttr) throws InternalErrorException { if (beanAttr == null) return null; Authorship authorship = new Authorship(); authorship.setId(Integer.valueOf(beanAttr.get("id")).intValue()); authorship.setPublicationId(Integer.valueOf(beanAttr.get("publicationId")).intValue()); authorship.setUserId(Integer.valueOf(beanAttr.get("userId")).intValue()); authorship.setCreatedBy(BeansUtils.eraseEscaping(beanAttr.get("createdBy"))); authorship.setCreatedByUid( (beanAttr.get("createdByUid").equals("\\0")) ? null : Integer.valueOf(beanAttr.get("createdByUid")).intValue()); if (BeansUtils.eraseEscaping(beanAttr.get("createdDate")) == null) authorship.setCreatedDate(null); else { Date date; try { date = BeansUtils.DATE_FORMATTER.parse(BeansUtils.eraseEscaping(beanAttr.get("createdDate"))); } catch (ParseException ex) { throw new InternalErrorException("Error when date was parsing from String to Date.", ex); } authorship.setCreatedDate(date); } return authorship; }
private static Vo createVo(Map<String, String> beanAttr) { if (beanAttr == null) return null; Vo vo = new Vo(); vo.setId(Integer.valueOf(beanAttr.get("id")).intValue()); vo.setName(BeansUtils.eraseEscaping(beanAttr.get("name"))); vo.setShortName(BeansUtils.eraseEscaping(beanAttr.get("shortName"))); return vo; }
private static Facility createFacility(Map<String, String> beanAttr) { if (beanAttr == null) return null; Facility facility = new Facility(); facility.setId(Integer.valueOf(beanAttr.get("id")).intValue()); facility.setName(BeansUtils.eraseEscaping(beanAttr.get("name"))); facility.setType(BeansUtils.eraseEscaping(beanAttr.get("type"))); return facility; }
private static ExtSource createExtSource(Map<String, String> beanAttr) { if (beanAttr == null) return null; ExtSource extSource = new ExtSource(); extSource.setId(Integer.valueOf(beanAttr.get("id")).intValue()); extSource.setName(BeansUtils.eraseEscaping(beanAttr.get("name"))); extSource.setType(BeansUtils.eraseEscaping(beanAttr.get("type"))); return extSource; }
private static Destination createDestination(Map<String, String> beanAttr) { if (beanAttr == null) return null; Destination destination = new Destination(); destination.setId(Integer.valueOf(beanAttr.get("id")).intValue()); destination.setDestination(BeansUtils.eraseEscaping(beanAttr.get("destination"))); destination.setType(BeansUtils.eraseEscaping(beanAttr.get("type"))); return destination; }
private static AttributeDefinition createAttributeDefinition(Map<String, String> beanAttr) { if (beanAttr == null) return null; AttributeDefinition attributeDefinition = new AttributeDefinition(); attributeDefinition.setId(Integer.valueOf(beanAttr.get("id")).intValue()); attributeDefinition.setFriendlyName(BeansUtils.eraseEscaping(beanAttr.get("friendlyName"))); attributeDefinition.setNamespace(BeansUtils.eraseEscaping(beanAttr.get("namespace"))); attributeDefinition.setType(BeansUtils.eraseEscaping(beanAttr.get("type"))); return attributeDefinition; }
private static Owner createOwner(Map<String, String> beanAttr) { if (beanAttr == null) return null; Owner owner = new Owner(); owner.setId(Integer.valueOf(beanAttr.get("id")).intValue()); owner.setName(BeansUtils.eraseEscaping(beanAttr.get("name"))); owner.setContact(BeansUtils.eraseEscaping(beanAttr.get("contact"))); owner.setTypeByString(BeansUtils.eraseEscaping(beanAttr.get("type"))); return owner; }
private static Member createMember(Map<String, String> beanAttr) { if (beanAttr == null) return null; Member member = new Member(); member.setId(Integer.valueOf(beanAttr.get("id")).intValue()); member.setUserId(Integer.valueOf(beanAttr.get("userId")).intValue()); member.setVoId(Integer.valueOf(beanAttr.get("voId")).intValue()); member.setStatus(BeansUtils.eraseEscaping(beanAttr.get("status"))); member.setMembershipType(BeansUtils.eraseEscaping(beanAttr.get("type"))); return member; }
private static Resource createResource(Map<String, String> beanAttr) { if (beanAttr == null) return null; Resource resource = new Resource(); resource.setId(Integer.valueOf(beanAttr.get("id")).intValue()); resource.setVoId(Integer.valueOf(beanAttr.get("voId")).intValue()); resource.setFacilityId(Integer.valueOf(beanAttr.get("facilityId")).intValue()); resource.setName(BeansUtils.eraseEscaping(beanAttr.get("name"))); resource.setDescription(BeansUtils.eraseEscaping(beanAttr.get("description"))); return resource; }
private static Group createGroup(Map<String, String> beanAttr) { if (beanAttr == null) return null; Group group = new Group(); if (beanAttr.get("parentGroupId").equals("\\0")) group.setParentGroupId(null); else group.setParentGroupId(Integer.valueOf(beanAttr.get("parentGroupId"))); group.setId(Integer.valueOf(beanAttr.get("id")).intValue()); group.setName(BeansUtils.eraseEscaping(beanAttr.get("name"))); group.setDescription(BeansUtils.eraseEscaping(beanAttr.get("description"))); group.setVoId(Integer.valueOf(beanAttr.get("voId"))); return group; }
// -------------------------------------------------------------------------- // --------------------------BEANS CREATORS--------------------------------- private static User createUser(Map<String, String> beanAttr) { if (beanAttr == null) return null; User user = new User(); user.setId(Integer.valueOf(beanAttr.get("id")).intValue()); user.setTitleBefore(BeansUtils.eraseEscaping(beanAttr.get("titleBefore"))); user.setTitleAfter(BeansUtils.eraseEscaping(beanAttr.get("titleAfter"))); user.setFirstName(BeansUtils.eraseEscaping(beanAttr.get("firstName"))); user.setLastName(BeansUtils.eraseEscaping(beanAttr.get("lastName"))); user.setMiddleName(BeansUtils.eraseEscaping(beanAttr.get("middleName"))); user.setServiceUser(Boolean.valueOf(beanAttr.get("serviceAccount")).booleanValue()); return user; }
private static Attribute createAttribute(Map<String, String> beanAttr) throws InternalErrorException { if (beanAttr == null) return null; Attribute attribute = new Attribute(); attribute.setId(Integer.valueOf(beanAttr.get("id")).intValue()); attribute.setFriendlyName(BeansUtils.eraseEscaping(beanAttr.get("friendlyName"))); attribute.setNamespace(BeansUtils.eraseEscaping(beanAttr.get("namespace"))); attribute.setType(BeansUtils.eraseEscaping(beanAttr.get("type"))); attribute.setValue( BeansUtils.stringToAttributeValue( BeansUtils.eraseEscaping(beanAttr.get("value")), attribute.getType())); return attribute; }
private static Host createHost(Map<String, String> beanAttr) throws InternalErrorException { if (beanAttr == null) return null; Host host = new Host(); host.setId(Integer.valueOf(beanAttr.get("id")).intValue()); host.setHostname(BeansUtils.eraseEscaping(beanAttr.get("hostname"))); return host; }
private static Service createService(Map<String, String> beanAttr) { if (beanAttr == null) return null; Service service = new Service(); service.setId(Integer.valueOf(beanAttr.get("id")).intValue()); service.setName(BeansUtils.eraseEscaping(beanAttr.get("name"))); return service; }
private static ResourceTag createResourceTag(Map<String, String> beanAttr) { if (beanAttr == null) return null; ResourceTag resourceTag = new ResourceTag(); resourceTag.setId(Integer.valueOf(beanAttr.get("id")).intValue()); resourceTag.setVoId(Integer.valueOf(beanAttr.get("voId")).intValue()); resourceTag.setTagName(BeansUtils.eraseEscaping(beanAttr.get("tagName"))); return resourceTag; }
private static RichResource createRichResource(Map<String, String> beanAttr) { if (beanAttr == null) return null; RichResource richResource = new RichResource(); richResource.setId(Integer.valueOf(beanAttr.get("id")).intValue()); richResource.setVoId(Integer.valueOf(beanAttr.get("voId")).intValue()); richResource.setFacilityId(Integer.valueOf(beanAttr.get("facilityId")).intValue()); richResource.setName(BeansUtils.eraseEscaping(beanAttr.get("name"))); richResource.setDescription(BeansUtils.eraseEscaping(beanAttr.get("description"))); // Parse and get Vo Vo vo; if (beanAttr.get("vo").equals("\\0")) vo = null; else { List<Pair<String, Map<String, String>>> voMap = beansToMap(beanAttr.get("vo")); vo = createVo(voMap.get(0).getRight()); } richResource.setVo(vo); // Parse and get Facility Facility facility; if (beanAttr.get("facility").equals("\\0")) facility = null; else { List<Pair<String, Map<String, String>>> facilityMap = beansToMap(beanAttr.get("facility")); facility = createFacility(facilityMap.get(0).getRight()); } richResource.setFacility(facility); // Parse and get List of ResourceTags List<ResourceTag> tags = new ArrayList<ResourceTag>(); if (beanAttr.get("resourceTags").equals("\\0")) tags = null; else { List<Pair<String, Map<String, String>>> tagsList = beansToMap(beanAttr.get("resourceTags")); for (Pair<String, Map<String, String>> p : tagsList) { ResourceTag tag = createResourceTag(p.getRight()); tags.add(tag); } } richResource.setResourceTags(tags); return richResource; }
private static RichDestination createRichDestination(Map<String, String> beanAttr) { if (beanAttr == null) return null; RichDestination richDestination = new RichDestination(); richDestination.setId(Integer.valueOf(beanAttr.get("id")).intValue()); richDestination.setDestination(BeansUtils.eraseEscaping(beanAttr.get("destination"))); richDestination.setType(BeansUtils.eraseEscaping(beanAttr.get("type"))); // Parse and get service Service service; if (beanAttr.get("service").equals("\\0")) service = null; else { List<Pair<String, Map<String, String>>> serviceList = beansToMap(beanAttr.get("service")); service = createService(serviceList.get(0).getRight()); } richDestination.setService(service); // Parse and get Facility Facility facility; if (beanAttr.get("facility").equals("\\0")) facility = null; else { List<Pair<String, Map<String, String>>> facilityList = beansToMap(beanAttr.get("facility")); facility = createFacility(facilityList.get(0).getRight()); } richDestination.setFacility(facility); return richDestination; }
private static UserExtSource createUserExtSource(Map<String, String> beanAttr) { if (beanAttr == null) return null; UserExtSource userExtSource = new UserExtSource(); userExtSource.setId(Integer.valueOf(beanAttr.get("id")).intValue()); userExtSource.setLoa(Integer.valueOf(beanAttr.get("loa")).intValue()); userExtSource.setLogin(BeansUtils.eraseEscaping(beanAttr.get("login"))); // Parse and get ExtSource ExtSource extSource; if (beanAttr.get("source").equals("\\0")) extSource = null; else { List<Pair<String, Map<String, String>>> extSourceList = beansToMap(beanAttr.get("source")); extSource = createExtSource(extSourceList.get(0).getRight()); } userExtSource.setExtSource(extSource); return userExtSource; }