/* * (non-Javadoc) * * @see ca.unb.cs.pcsf.db.DBAccessService#getCreatorById(java.lang.String) */ public Creator getCreatorById(String id) { logger.debug(LOGPRE + "getCreatorById() start" + LOGPRE); Creator creator = new Creator(); String selectRequest = "select * from `" + DOMAIN_CREATOR + "`"; List<Item> items = this.getDataFromDomain(selectRequest); Item findItem = new Item(); if (!items.isEmpty()) { for (Item item : items) { if (item.getName().equals(id)) { findItem = item; break; } } } if (findItem != null) { creator.setId(findItem.getName()); for (Attribute attribute : findItem.getAttributes()) { if (attribute.getName().equals(CREATOR_ATTRIBUTE_NAME)) creator.setName(attribute.getValue()); if (attribute.getName().equals(CREATOR_ATTRIBUTE_PASSWORD)) creator.setPassword(attribute.getValue()); if (attribute.getName().equals(CREATOR_ATTRIBUTE_EMAIL)) creator.setEmail(attribute.getValue()); } } logger.debug(LOGPRE + "getCreatorById() end" + LOGPRE); return creator; }
/* * (non-Javadoc) * * @see ca.unb.cs.pcsf.db.DBAccessService#getCreatorByName(java.lang.String) */ public Creator getCreatorByName(String userName) { logger.debug(LOGPRE + "getCreatorByName() start" + LOGPRE); Creator creator = new Creator(); String selectRequest = "select * from `" + DOMAIN_CREATOR + "` where " + CREATOR_ATTRIBUTE_NAME + " = '" + userName + "'"; Item item = this.getDataFromDomain(selectRequest).get(0); creator.setId(item.getName()); for (Attribute attribute : item.getAttributes()) { if (attribute.getName().equals(CREATOR_ATTRIBUTE_NAME)) creator.setName(attribute.getValue()); if (attribute.getName().equals(CREATOR_ATTRIBUTE_PASSWORD)) creator.setPassword(attribute.getValue()); if (attribute.getName().equals(CREATOR_ATTRIBUTE_EMAIL)) creator.setEmail(attribute.getValue()); } logger.debug(LOGPRE + "getCreatorByName() end" + LOGPRE); return creator; }