yaz/commit

FIX only use annotation made by user

authorMichiel Hildebrand
Sun Nov 6 21:25:06 2011 +0100
committerMichiel Hildebrand
Sun Nov 6 21:25:06 2011 +0100
commit01472c386722178e8f547e21544054b5b602b961
tree3d663ab4f703de4156a5274234cab3b8dd570007
parentc57f3a0452ad566936c7d483858c900be9e73314
Diff style: patch stat
diff --git a/api/edm_export.pl b/api/edm_export.pl
index 4e0df77..357e7ed 100644
--- a/api/edm_export.pl
+++ b/api/edm_export.pl
@@ -32,6 +32,9 @@ http_yaz_sip_update(Request) :-
 	http_parameters(Request,
 			[ video(Video,
 				[description('Current video')]),
+			  process(Process,
+				  [optional(true),
+				   description('Gardening process')]),
 			  shotLevel(ShotLevel,
 				    [boolean, default(true),
 				     description('When set to true only annotations at shot level are returned')
@@ -43,8 +46,10 @@ http_yaz_sip_update(Request) :-
 				    [boolean, default(false),
 				     description('When true only tags that are entered by >1 user are shown')])
 			]),
+	 % end TagGarden process
+	end_user_process(Process),
 	(   ShotLevel
-	->  video_shot_annotations(Video, Annotations)
+	->  video_shot_annotations(Video, Process, Annotations)
 	;   video_annotations(Video, Annotations0,
 			      [interval(Interval),
 			       confirmed(Confirmed)
@@ -53,14 +58,9 @@ http_yaz_sip_update(Request) :-
 	),
 	Id = '11111',
 	length(Annotations, Count),
-	%convert_annotations(Annotations, _XMLString),
-	%submit_mpeg(Id, XMLString),
-	% end TagGarden process
-	(   current_user_process(Process)
-	->  end_user_process(Process)
-	;   true
-	),
+	% convert EDM
 	conv_url(SubmitURL),
+	update_url(UpdateURL),
 	edm_triples(Annotations, Video, Triples),
 	new_memory_file(MemFile),
 	open_memory_file(MemFile, write, Stream),
@@ -83,11 +83,15 @@ http_yaz_sip_update(Request) :-
 			  div(class('yui3-g fields'),
 			      [ div(class('yui3-u-1-2'),
 				    [h3('Europeana Data Model'),
-				     textarea([id(edm),style('width:100%;height:500px')], EDM)
+				     textarea([id(edm),style('width:100%;height:400px')], EDM)
 				    ]),
 				div(class('yui3-u-1-2'),
 				    [h3('MPEG-7'),
-				     textarea([id(mpeg),style('width:100%;height:500px')], MPEG)
+				     form([method('POST'), action(UpdateURL)],
+					  [ input([type(hidden), name(id), value(Id)], []),
+					    textarea([id(mpeg),name(file),style('width:100%;height:400px')], MPEG),
+					    input([type(submit), value('Submit')])
+					  ])
 				    ])
 			      ]),
 			   script(type('text/javascript'),
@@ -129,6 +133,9 @@ http_api_edm_export(Request) :-
 	http_parameters(Request,
 			[ video(Video,
 				[description('Current video')]),
+			  process(Process,
+				  [optional(true),
+				   description('Gardening process')]),
 			  shotLevel(ShotLevel,
 				    [boolean, default(true),
 				     description('When set to true only annotations at shot level are returned')
@@ -151,7 +158,7 @@ http_api_edm_export(Request) :-
 				 ])
 			]),
 	(   ShotLevel
-	->  video_shot_annotations(Video, Annotations1)
+	->  video_shot_annotations(Video, Process, Annotations1)
 	;   video_annotations(Video, Annotations0,
 			      [interval(Interval),
 			       confirmed(Confirmed)
@@ -310,12 +317,12 @@ get_result(DocURL, Result) :-
 	memberchk(status=Status, Pairs),
 	(   Status = 'PENDING'
 	->  %memberchk(retryafter=Wait, Pairs),
-	    sleep(2),
+	    sleep(1),
 	    get_result(DocURL, Result)
 	;   Status = 'COMPLETED'
 	->  atom_concat(DocURL, '/result', ResultURL),
-	    http_get(ResultURL, Result, [])
-	    %http_delete(DocURL, _, [])
+	    http_get(ResultURL, Result, []),
+	    http_delete(DocURL, _, [])
 	;   Result = ''
 	).
 
diff --git a/applications/yaz_garden.pl b/applications/yaz_garden.pl
index 2a22514..41dde2e 100644
--- a/applications/yaz_garden.pl
+++ b/applications/yaz_garden.pl
@@ -69,22 +69,11 @@ reconcile_source(freebase,
 %	Emit an HTML page to link tags to concepts.
 
 http_yaz_garden_accept(Request) :-
-	ensure_logged_on(User0),
+	ensure_logged_on(_),
 	http_parameters(Request,
 			[ video(Video,
 				[description('Current video')])
 			]),
-	user_property(User0, url(User)),
-	%User = pprime_test, % hack for testbed
-	(   current_user_process(Process),
-	    rdf(Process, rdf:type, pprime:'TagGarden'),
-	    rdf(Process, opmv:used, Video)
-	->  true
-	;   create_user_process(User, [rdf:type=pprime:'TagGarden',
-				       opmv:used=Video
-				      ], Process)
-	),
-	start_user_process(Process),
 	http_link_to_id(http_yaz_shot, [video(Video)], Garden),
 	throw(http_reply(moved_temporary(Garden))).
 /*
@@ -125,15 +114,11 @@ visible_garden_process(Process) :-
 %	Emit an HTML page to link tags to concepts.
 
 http_yaz_garden(Request) :-
+	ensure_logged_on(User0),
+	user_property(User0, url(User)),
 	http_parameters(Request,
 			[ video(Video,
 				[description('Current video')]),
-			  process(Process,
-			       [optional(true),
-				desription('When set only annotations within this process are shown')]),
-			  user(User,
-				[optional(true),
-				 description('When set only annotations from this user are shown')]),
 			  interval(Interval,
 				   [default(10), number,
 				    description('When set one entry per tag is returned in interval (in milliseconds)')]),
@@ -142,11 +127,18 @@ http_yaz_garden(Request) :-
 				     description('When true only tags that are entered by >1 user are shown')])
 			]),
 	Options0 = [video(Video),
-		    process(Process),
-		    user(User),
 		    confirmed(Confirmed),
 		    interval(Interval)
 		  ],
+	(   current_user_process(Process),
+	    rdf(Process, rdf:type, pprime:'TagGarden'),
+	    rdf(Process, opmv:used, Video)
+	->  true
+	;   create_user_process(User, [rdf:type=pprime:'TagGarden',
+				       opmv:used=Video
+				      ], Process)
+	),
+	start_user_process(Process),
 	delete_nonground(Options0, Options),
 	video_annotations(Video, As0, Options),
 	sort_by_arg(As0, 2, Annotations),
diff --git a/applications/yaz_shot_annotation.pl b/applications/yaz_shot_annotation.pl
index d8d3c84..c682a31 100644
--- a/applications/yaz_shot_annotation.pl
+++ b/applications/yaz_shot_annotation.pl
@@ -1,7 +1,7 @@
 :- module(yaz_shot_annotation,
 	  [assert_shot_data/0,
 	   load_shot_data/0,
-	   video_shot_annotations/2
+	   video_shot_annotations/3
 	  ]).
 
 :- use_module(library(http/http_dispatch)).
@@ -68,24 +68,36 @@ reconcile_source(subject,
 %	Emit an HTML page to link tags to concepts.
 
 http_yaz_shot(Request) :-
+	ensure_logged_on(User0),
+	user_property(User0, url(User)),
 	http_parameters(Request,
 			[ video(Video,
 				[description('Current video')])
 			]),
+	(   current_user_process(Process),
+	    rdf(Process, rdf:type, pprime:'TagGarden'),
+	    rdf(Process, opmv:used, Video)
+	->  true
+	;   create_user_process(User, [rdf:type=pprime:'TagGarden',
+				       opmv:used=Video
+				      ], Process)
+	),
+	start_user_process(Process),
 	findall(Id=json([label=Label,url=URL,parameters=Parameters]),
 		reconcile_source(Id,Label,URL,Parameters), Sources),
 	findall({uri:Shot, startTime:Start, duration:Duration},
 		video_shot(Video, Shot, Start, Duration),
 		Shots),
-	html_page(Video, Shots, json(Sources)).
+	html_page(Video, Process, Shots, json(Sources)).
 
 
-%%	html_page(+Video, +Annotations)
+%%	html_page(+Video, +Process, +Shots, +Annotations)
 %
 %	Emit an HTML page for concept gardening
 
-html_page(Video, Shots, Sources) :-
-	http_link_to_id(http_yaz_sip_update, [video(Video)], Update),
+html_page(Video, Process, Shots, Sources) :-
+	http_link_to_id(http_yaz_sip_update,
+			[video(Video), process(Process)], Update),
 	reply_html_page(yaz,
 			[ title(['YAZ - ', Video])
 			],
@@ -295,15 +307,17 @@ http_data_shot_get_annotations(Request) :-
 			[ shot(Shot,
 			       [description('URI of the shot')])
 			]),
+	current_user_process(Process),
 	findall(Type-json([entry=E, value=Value, label=Label]),
-		shot_annotation(Shot, Value, Label, Type, E),
+		shot_annotation(Shot, Value, Label, Type, Process, E),
 		As),
 	group_pairs_by_key(As, Annotations),
 	reply_json(json(Annotations)).
 
 http_data_shot_set_annotation(Request) :-
+	ensure_logged_on(_),
 	http_parameters(Request,
-			[ video(Video,
+			[ video(_Video,
 				[description('URI of the video')]),
 			  shot(Shot,
 			       [description('URI of the shot')]),
@@ -314,26 +328,16 @@ http_data_shot_set_annotation(Request) :-
 			  type(Type,
 				[description('type of annotation')])
 			]),
-	logged_on(User0, anonymous),
-	user_property(User0, url(User)),
-	(   current_user_process(Process),
-	    rdf(Process, rdf:type, pprime:'ShotGarden'),
-	    rdf(Process, opmv:used, Video)
-	->  true
-	;   create_user_process(User, [rdf:type=pprime:'ShotGarden',
-				       opmv:used=Video
-				      ], _GardenProcess)
-	),
 	rdfh_transaction(assert_shot_annotation(Shot, Value, Label, Type, Event)),
 	reply_json(json([shot=Shot,value=Value,label=Label,entry=Event])).
 
 
 
-shot_annotation(Shot, Value, Label, Type, R) :-
-	rdf(R, pprime:shot, Shot),
-	rdf(R, pprime:value, Value),
-	rdf(R, pprime:type, Type),
-	rdf(R, pprime:label, Label).
+shot_annotation(Shot, Value, Label, Type, Process, R) :-
+	rdf(R, pprime:shot, Shot, Process),
+	rdf(R, pprime:value, Value, Process),
+	rdf(R, pprime:type, Type, Process),
+	rdf(R, pprime:label, Label, Process).
 
 assert_shot_annotation(Shot, Value, Label, Type, R) :-
 	rdf_bnode(R),
@@ -400,13 +404,17 @@ to_number(N,N).
 
 
 
+%%	video_shot_annotations(+VideoURL, ?Process, -Annotations)
+%
+%	Annotations are shot annotations for VideoURL.
+%
 
-video_shot_annotations(Video, Annotations) :-
+video_shot_annotations(Video, Process, Annotations) :-
 	A = shot_annotation(Shot, StartTime, Duration, Values),
 	findall(A,
 		(   video_shot(Video, Shot, StartTime, Duration),
 		    findall(concept(URI,Label,Type),
-			    shot_annotation(Shot, URI, Label, Type, _),
+			    shot_annotation(Shot, URI, Label, Type, Process, _),
 			    Values)
 		),
 		Annotations).
diff --git a/web/js/tagplayer/tagLinker.js b/web/js/tagplayer/tagLinker.js
index 5fbb87b..02cc109 100644
--- a/web/js/tagplayer/tagLinker.js
+++ b/web/js/tagplayer/tagLinker.js
@@ -158,10 +158,12 @@ YUI.add('tag-linker', function(Y) {
 		formatItem : function(item) {
 			var id = item.id,
 				name = item.name,
+				entries = item.entries||[],
 				types = item.type||[];
-				
+			
+			//var size = (log((20*max((Count-Min),1)) / max((Max-Min),5))) * 10
 			var html = "<input type=radio name='reconcileItem' value='"+id+"'>";
-			html += "<span class='name'>"+name+"</span>";
+			html += "<span class='name' style='font-size:"+Size+"em'>"+name+"</span>";
 			html += "<div class='types'>";
 			for (var i=0; i < (types.length||3); i++) {
 				html += "<span class='type'>"+types[i].name+"</span>";