private final String propertyKey;
- protected HasReviewPropertyCondition(String propertyKey) {
+ public HasReviewPropertyCondition(String propertyKey) {
super(false);
Preconditions.checkArgument(!Strings.isNullOrEmpty(propertyKey));
this.propertyKey = propertyKey;
}
- protected final String getPropertyKey() {
+ public final String getPropertyKey() {
return propertyKey;
}
# POST
def execute
bad_request('Missing review id') unless params[:id]
- @review = Review.find(params[:id], :include => ['project'])
+ review = Review.find(params[:id], :include => ['project'])
- access_denied unless has_rights_to_modify?(@review.resource)
+ access_denied unless has_rights_to_modify?(review.resource)
bad_request('Missing command') if params[:command].blank?
error_message = nil
begin
- RuleFailure.execute_command(params[:command], @review.violation, @review.resource.project, current_user, params)
+ RuleFailure.execute_command(params[:command], review.violation, review.resource.project, current_user, params)
rescue Exception => e
error_message=Api::Utils.exception_message(e, :backtrace => false)
end
- @review.reload
- render :partial => "project_reviews/view", :locals => {:review => @review, :error_message => error_message}
+
+ ActiveRecord::Base.uncached() do
+ review.clean_violation_cache
+ review.reload
+
+ # TODO remove this ugly workaround to bypass ActiveRecord cache....
+ review.violation.review=review
+ end
+ render :partial => "project_reviews/review", :locals => {:review => review, :error_message => error_message}
end
def rule_failure
@rule_failure ||=
begin
- # We need to manually run this DB request as the real relation Reviews-RuleFailures is 1:n but we want only 1 violation
- # (more than 1 violation can have the same "permanent_id" when several analyses are run in a small time frame)
- RuleFailure.find(:first, :conditions => {:permanent_id => rule_failure_permanent_id}, :order => 'id desc')
+ # We need to manually run this DB request as the real relation Reviews-RuleFailures is 1:n but we want only 1 violation
+ # (more than 1 violation can have the same "permanent_id" when several analyses are run in a small time frame)
+ RuleFailure.find(:first, :conditions => {:permanent_id => rule_failure_permanent_id}, :order => 'id desc')
end
end
+ def clean_violation_cache
+ @rule_failure=nil
+ end
#
#
:url => {:controller => "project_reviews", :action => "action_plan_form", :id => review.id},
:update => "actionForm",
:complete => "$('actionButtons').remove();$('actionForm').show();$('selectSeverity').focus();" -%>
-
<%
- screens = review.violation.available_java_screens(current_user)
- screens.each do |screen|
+ end
%>
- <%= button_to_remote message("reviews.command.#{screen.getCommandKey()}.button"),
- :url => {:controller => "project_reviews", :action => "screen", :id => review.id, :command => screen.getCommandKey()},
- :update => "actionForm",
- :complete => "$('actionButtons').remove();$('actionForm').show();$('actionText').focus();" -%>
<%
- end
- end
+ puts "-------------- in template: #{review.violation.review.data} versus #{review.data}"
+ if review.violation
+ screens = review.violation.available_java_screens(current_user)
+ screens.each do |screen|
%>
+ <%= button_to_remote message("reviews.command.#{screen.getCommandKey()}.button"),
+ :url => {:controller => "project_reviews", :action => "screen", :id => review.id, :command => screen.getCommandKey()},
+ :update => "actionForm",
+ :complete => "$('actionButtons').remove();$('actionForm').show();$('actionText').focus();" -%>
+ <%
+ end
+ end
+ %>
</div>
<% end %>