Exemplo n.º 1
0
 @Move
 public void move(Musician musician, MusiciansController newParent, String newName) {
   Transaction tx = SessionManager.session().beginTransaction();
   musician.setName(newName);
   if (musician.getContactUid() == null) {
     musician.setContactUid(UUID.randomUUID().toString());
   }
   SessionManager.session().save(musician);
   SessionManager.session().flush();
   tx.commit();
 }
Exemplo n.º 2
0
 @Delete
 public void deleteMusician(Musician musician) {
   Transaction tx = SessionManager.session().beginTransaction();
   if (musician.getBandMembers() != null) {
     for (BandMember bm : musician.getBandMembers()) {
       SessionManager.session().delete(bm);
     }
   }
   SessionManager.session().delete(musician);
   SessionManager.session().flush();
   tx.commit();
 }
Exemplo n.º 3
0
 @MakeCollection
 public Musician createAndSaveMusician(MusiciansController root, String newName) {
   Transaction tx = SessionManager.session().beginTransaction();
   Musician m = new Musician();
   m.setCreatedDate(new Date());
   m.setModifiedDate(new Date());
   m.setName(newName);
   SessionManager.session().save(m);
   SessionManager.session().flush();
   tx.commit();
   return m;
 }
Exemplo n.º 4
0
 @Post(bindData = true)
 public Musician saveMusician(Musician musician) {
   log.info("saveMusician: " + musician.getName());
   Transaction tx = SessionManager.session().beginTransaction();
   if (musician.getContactUid() == null) {
     musician.setContactUid(UUID.randomUUID().toString());
   }
   musician.setModifiedDate(new Date());
   SessionManager.session().save(musician);
   SessionManager.session().flush();
   tx.commit();
   log.info("saved musician");
   return musician;
 }
Exemplo n.º 5
0
 @ChildrenOf
 @Users // ties in with the @AccessControlList and @Authenticate methods below
 public List<Musician> getMusicians(MusiciansController root) {
   List<Musician> list = Musician.findAll(SessionManager.session());
   System.out.println("musicians=" + list.size());
   return list;
 }
Exemplo n.º 6
0
 @ChildOf
 @Users
 public Musician findMusicianByName(MusiciansController root, String name) {
   return Musician.find(name, SessionManager.session());
 }