@Test(expected = IllegalArgumentException.class) public void testGetByNameAndNamespace_null_type_id() { getKewTypeBoService().getTypeByNameAndNamespace(null, "KEW_TEST"); }
@Override public KewTypeDefinition getTypeByNameAndNamespace(final String name, final String namespace) { if (StringUtils.isBlank(name)) { throw new RiceIllegalArgumentException("name is blank"); } if (StringUtils.isBlank(namespace)) { throw new RiceIllegalArgumentException("namespace is blank"); } QueryByCriteria.Builder criteria = QueryByCriteria.Builder.create(); criteria.setPredicates(equal("name", name), equal("namespace", namespace)); List<KewTypeBo> myTypes = dataObjectService.findMatching(KewTypeBo.class, criteria.build()).getResults(); if (myTypes.isEmpty()) { return null; } else if (myTypes.size() == 1) { return KewTypeBo.to(myTypes.get(0)); } else { throw new RiceIllegalStateException("More than one type found for the given name and namespace - (name=" + name + ", namespace=" + namespace + ")."); } }
KewTypeBoServiceImpl implements KewTypeRepositoryService { @Override public KewTypeDefinition getTypeByNameAndNamespace(final String name, final String namespace) { if (StringUtils.isBlank(name)) { throw new RiceIllegalArgumentException("name is blank"); } if (StringUtils.isBlank(namespace)) { throw new RiceIllegalArgumentException("namespace is blank"); } QueryByCriteria.Builder criteria = QueryByCriteria.Builder.create(); criteria.setPredicates(equal("name", name), equal("namespace", namespace)); List<KewTypeBo> myTypes = dataObjectService.findMatching(KewTypeBo.class, criteria.build()).getResults(); if (myTypes.isEmpty()) { return null; } else if (myTypes.size() == 1) { return KewTypeBo.to(myTypes.get(0)); } else { throw new RiceIllegalStateException("More than one type found for the given name and namespace - (name=" + name + ", namespace=" + namespace + ")."); } } }
KewTypeBoServiceImpl implements KewTypeRepositoryService { @Override public KewTypeDefinition getTypeByNameAndNamespace(final String name, final String namespace) { if (StringUtils.isBlank(name)) { throw new RiceIllegalArgumentException("name is blank"); } if (StringUtils.isBlank(namespace)) { throw new RiceIllegalArgumentException("namespace is blank"); } QueryByCriteria.Builder criteria = QueryByCriteria.Builder.create(); criteria.setPredicates(equal("name", name), equal("namespace", namespace)); List<KewTypeBo> myTypes = dataObjectService.findMatching(KewTypeBo.class, criteria.build()).getResults(); if (myTypes.isEmpty()) { return null; } else if (myTypes.size() == 1) { return KewTypeBo.to(myTypes.get(0)); } else { throw new RiceIllegalStateException("More than one type found for the given name and namespace - (name=" + name + ", namespace=" + namespace + ")."); } }  }
KewTypeBoServiceImpl implements KewTypeRepositoryService { @Override public KewTypeDefinition getTypeByNameAndNamespace(final String name, final String namespace) { if (StringUtils.isBlank(name)) { throw new RiceIllegalArgumentException("name is blank"); } if (StringUtils.isBlank(namespace)) { throw new RiceIllegalArgumentException("namespace is blank"); } QueryByCriteria.Builder criteria = QueryByCriteria.Builder.create(); criteria.setPredicates(equal("name", name), equal("namespace", namespace)); List<KewTypeBo> myTypes = dataObjectService.findMatching(KewTypeBo.class, criteria.build()).getResults(); if (myTypes.isEmpty()) { return null; } else if (myTypes.size() == 1) { return KewTypeBo.to(myTypes.get(0)); } else { throw new RiceIllegalStateException("More than one type found for the given name and namespace - (name=" + name + ", namespace=" + namespace + ")."); } }  @Override KewTypeDefinition createKewType(KewTypeDefinition kewType); @Override void updateKewType(KewTypeDefinition kewType); @Override KewTypeDefinition getTypeById(final String id); @Override KewTypeDefinition getTypeByNameAndNamespace(final String name, final String namespace); @Override List<KewTypeDefinition> findAllTypesByNamespace(final String namespace); @Override List<KewTypeDefinition> findAllTypes(); void setDataObjectService(final DataObjectService dataObjectService); @Override void createKewTypeAttribute(KewTypeAttribute kewTypeAttribute); @Override void updateKewTypeAttribute(KewTypeAttribute kewTypeAttribute); }
KewTypeBoServiceImpl implements KewTypeRepositoryService { @Override public KewTypeDefinition getTypeByNameAndNamespace(final String name, final String namespace) { if (StringUtils.isBlank(name)) { throw new RiceIllegalArgumentException("name is blank"); } if (StringUtils.isBlank(namespace)) { throw new RiceIllegalArgumentException("namespace is blank"); } QueryByCriteria.Builder criteria = QueryByCriteria.Builder.create(); criteria.setPredicates(equal("name", name), equal("namespace", namespace)); List<KewTypeBo> myTypes = dataObjectService.findMatching(KewTypeBo.class, criteria.build()).getResults(); if (myTypes.isEmpty()) { return null; } else if (myTypes.size() == 1) { return KewTypeBo.to(myTypes.get(0)); } else { throw new RiceIllegalStateException("More than one type found for the given name and namespace - (name=" + name + ", namespace=" + namespace + ")."); } }  @Override KewTypeDefinition createKewType(KewTypeDefinition kewType); @Override void updateKewType(KewTypeDefinition kewType); @Override KewTypeDefinition getTypeById(final String id); @Override KewTypeDefinition getTypeByNameAndNamespace(final String name, final String namespace); @Override List<KewTypeDefinition> findAllTypesByNamespace(final String namespace); @Override List<KewTypeDefinition> findAllTypes(); void setDataObjectService(final DataObjectService dataObjectService); @Override void createKewTypeAttribute(KewTypeAttribute kewTypeAttribute); @Override void updateKewTypeAttribute(KewTypeAttribute kewTypeAttribute);  }