use of org.molgenis.api.metadata.v3.model.Category in project uPMT by coco35700.
the class MainViewController method duplicate.
private Category duplicate(Category c) {
Category newc = new Category(c.getName());
newc.setColor(c.getColor());
for (Type t : c.getTypes()) {
newc.addType(t);
}
return newc;
}
use of org.molgenis.api.metadata.v3.model.Category in project molgenis by molgenis.
the class AttributeResponseMapperImpl method getCategories.
private List<Category> getCategories(EntityType entityType) {
Repository<Entity> repository = metaDataService.getRepository(entityType).orElseThrow(() -> new UnknownRepositoryException(entityType.getId()));
Attribute idAttribute = entityType.getIdAttribute();
Attribute labelAttribute = entityType.getLabelAttribute();
return repository.query().findAll().map(entity -> Category.builder().setId(entity.get(idAttribute)).setLabel(entity.get(labelAttribute).toString()).build()).collect(toList());
}
use of org.molgenis.api.metadata.v3.model.Category in project springdoc-openapi-demos by springdoc.
the class PetApiDelegateImpl method initPets.
@PostConstruct
private void initPets() {
Category dogs = new Category().id(1L).name("Dogs");
Category cats = new Category().id(2L).name("Cats");
Category rabbits = new Category().id(3L).name("Rabbits");
Category lions = new Category().id(4L).name("Lions");
petRepository.save(createPet(1, cats, "Cat 1", new String[] { "url1", "url2" }, new String[] { "tag1", "tag2" }, Pet.StatusEnum.AVAILABLE));
petRepository.save(createPet(2, cats, "Cat 2", new String[] { "url1", "url2" }, new String[] { "tag2", "tag3" }, Pet.StatusEnum.AVAILABLE));
petRepository.save(createPet(3, cats, "Cat 3", new String[] { "url1", "url2" }, new String[] { "tag3", "tag4" }, Pet.StatusEnum.PENDING));
petRepository.save(createPet(4, dogs, "Dog 1", new String[] { "url1", "url2" }, new String[] { "tag1", "tag2" }, Pet.StatusEnum.AVAILABLE));
petRepository.save(createPet(5, dogs, "Dog 2", new String[] { "url1", "url2" }, new String[] { "tag2", "tag3" }, Pet.StatusEnum.SOLD));
petRepository.save(createPet(6, dogs, "Dog 3", new String[] { "url1", "url2" }, new String[] { "tag3", "tag4" }, Pet.StatusEnum.PENDING));
petRepository.save(createPet(7, lions, "Lion 1", new String[] { "url1", "url2" }, new String[] { "tag1", "tag2" }, Pet.StatusEnum.AVAILABLE));
petRepository.save(createPet(8, lions, "Lion 2", new String[] { "url1", "url2" }, new String[] { "tag2", "tag3" }, Pet.StatusEnum.AVAILABLE));
petRepository.save(createPet(9, lions, "Lion 3", new String[] { "url1", "url2" }, new String[] { "tag3", "tag4" }, Pet.StatusEnum.AVAILABLE));
petRepository.save(createPet(10, rabbits, "Rabbit 1", new String[] { "url1", "url2" }, new String[] { "tag3", "tag4" }, Pet.StatusEnum.AVAILABLE));
}
use of org.molgenis.api.metadata.v3.model.Category in project Happourse_online_study_web by infiq2000.
the class CourseUtil method getCategories.
public List<Category> getCategories() throws SQLException {
Connection myConn = null;
PreparedStatement myStmt = null;
ResultSet myRS = null;
myConn = dataSource.getConnection();
String sql = "SELECT * FROM category;";
myStmt = myConn.prepareStatement(sql);
myRS = myStmt.executeQuery();
List<Category> ls = new ArrayList<>();
while (myRS.next()) {
int cid = myRS.getInt("cid");
String name = myRS.getString("name");
Category category = new Category(cid, name);
ls.add(category);
}
myConn.close();
return ls;
}
Aggregations