1 / 69

KobrA2

KobrA2. WebApp Framework. WebService.SOS.ocl. context ServiceController::process(request: Request): Response post: let act = mvcAction->any(e | e.name = request.get('action').value) in result = act.do(request). WebService.SOT.ocl. context Response :: write ( value : String)

luka
Télécharger la présentation

KobrA2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. KobrA2 WebApp Framework

  2. WebService.SOS.ocl context ServiceController::process(request: Request): Response post: let act = mvcAction->any(e | e.name = request.get('action').value) in result = act.do(request)

  3. WebService.SOT.ocl contextResponse::write(value: String) post: responseBody = responseBody@pre.concat(value) context StringDictionary::get(key: String):String post: result = attribute->any(e | e.key = key).value context StringDictionary::set(key: String, value:String):String post: result = attribute@pre->any(e | e.key = key).value and attribute->select(e | e.key = key)->size() > 0 and attribute->select(e | e.key = key).value = value context StringDictionary::remove(key: String):String post: result = attribute@pre->any(e | e.key = key).value and attribute->select(e | e.key = key)->size() = 0

  4. WebService.ROS.ocl context WebService::process(request: Resquest):Response post: result = serviceController.process(request)

  5. ServiceController.SOS.ocl context ServiceController::process(request: Request): Response post: let act = mvcAction->any(e | e.name = request.get('action').value) in result = act.do(request)

  6. MVCModel.SOT.ocl contextModelEntity::all():Sequence(ModelEntity) post: result = entity contextModelEntity::put():ModelEntity post: models->includes(self) contextModelEntity::delete():ModelEntity post: models->excludes(self) context ModelEntity::get(eid : String):ModelEntity post: result = models->select(e | e.id = eid)

  7. KobrA2 PhotoAlbum as instanceofWebApp Framework

  8. AddComment.SOS -- do() simply calls addComment() method of PhotoManager contextAddComment::do(request:Request):Response post: let id:Integer = K2Library.createFromString(Integer, request.attribute->any( a:Attribute | a.key = 'photoId').value), us: String = request.attribute->any(a:Attribute | a.key = 'userName'), text:String = request.attribute->any(a:Attribute | a.key = 'text'), date: Timestamp = K2Library.createFromString(Timestamp, request.attribute->any( a:Attribute | a.key = 'date').value) in PhotoManager^addComment(id,us,date,text)

  9. AddPhoto.SOS -- do() simply calls addPhoto() method of PhotoManager context AddPhotos::do(request:Request):Response post: let photo:Photo = Photo.createFromString(request.attribute->any( a:Attribute | a.key = 'photo').value) in PhotoManager.addPhoto(photo)

  10. ListPhotos.SOS -- do() simply calls getAllPhotos() method of PhotoManager context ListPhotos::do(request:Request):Response post: let photos:Sequence(Photo) = PhotoManager.getAllPhotos() in result.oclAsType(Response).write(K2Library.convertToString(Sequence(Photo), photos)) and result.header.kind = HeaderKind::contentType and result.header.value = 'binary/octet-stream'

  11. PhotoManager.SOS (1/3) -- retrieveallphotos contextPhotoManager::getAllPhotos():Sequence(Photo) post: result = photos -- add a photo contextPhotoManager::addPhoto(photo:Photo) pre: notphotos->includes( photo) post: photos = photos@pre->including(photo) -- updates a photo's informations (ex. name, description) contextPhotoManager::updatePhoto(photo:Photo) pre: self.photos->exists( e:Photo | e.id = photo.id) post: self.photos->any( e:Photo | e.name = photo.name).data = photo.data and self.photos->any( e:Photo | e.name = photo.name).description = photo.description

  12. PhotoManager.SOS (2/3) -- add a comment to a photo - Breno's version context PhotoManager::addComment(id:Integer, us:String, c:String, data:Timestamp) pre: self.photos->exists( e:Photo | e.id = photo.id) post: let comment:Comment and comment.oclIsNew() and comment.userName = us and comment.date = data and comment.text = s in self.photos->any( e:Photo | e.id = id).comment->includes(comment) -- add a comment to a photo - Ramon's version context PhotoManager::addComment(photoId:Integer, userName:String, date:Timestamp, text:String) pre: self.photos->exists( e:Photo | e.id = photo.id) post: let photo:Photo = self.photos->any( e:Photo | e.photoId = photoId), c:Comment in c.oclIsNew() and c.userName = userName and c.date = date and c.text = text and photo.comments->includes(c) and photo.comments->size() = photo.comments@pre->size() + 1

  13. PhotoManager.SOS (3/3) -- completely removes a photo context PhotoManager::removePhoto(photo:Photo) pre: self.photos->exists( e:Photo | e.id = photo.id) post: self.photos->size() = self.photos@pre->size() - 1 and self.photos->excludes(photo)

More Related