<commit_before>/*
 *  (c) 2012 University of Bolton
 *  
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 * limitations under the License.
 */
package uk.ac.bolton.spaws.model.impl;

import java.util.Date;

import com.navnorth.learningregistry.LRActivity;

import uk.ac.bolton.spaws.model.IActor;
import uk.ac.bolton.spaws.model.IParadata;
import uk.ac.bolton.spaws.model.ISubmission;
import uk.ac.bolton.spaws.model.ISubmitter;

public class Submission implements ISubmission {

	private ISubmitter submitter;
	private String resourceURL;
	private IParadata action;
	private IActor actor;
	private Date updated;
	
	public Submission(){
	}
	
	public Submission(Actor actor, IParadata action, String resourceUrl){
		setActor(actor);
		setAction(action);
		setResourceURL(resourceUrl);
		setSubmitter(new Submitter());
	}
	
	public Submission(ISubmitter submitter, Actor actor, IParadata action, String resourceUrl){
		setActor(actor);
		setAction(action);
		setResourceURL(resourceUrl);
		setSubmitter(submitter);
	}
	
	public Submission(ISubmitter submitter, Actor actor, IParadata action, String resourceUrl, Date updated){
		setActor(actor);
		setAction(action);
		setResourceURL(resourceUrl);
		setSubmitter(submitter);
		setUpdated(updated);
	}

	/* (non-Javadoc)
	 * @see uk.ac.bolton.spaws.model.impl.ISubmission#getActivity()
	 */
	public LRActivity getActivity(){
		LRActivity activity = new LRActivity(getResourceURL(), getSubmitter().getSubmitter(), getSubmitter().getSubmitterType(), getSubmitter().getSubmissionTOS(), getSubmitter().getSubmissionAttribution(), getSubmitter().getSigner());
		if (getActor() != null)
			activity.addActor("actor", getActor().getName(), getActor().getUrl(), null);
		activity.addVerb(getAction().getVerb(), null, null, null, null);
		if (this.action.getContextUrl() != null){
			activity.addContextToVerb("Widget", this.action.getContextUrl(), "Detail page");
		}
		activity.addContent(getAction().getContent());
		getAction().addMeasure(activity);
		activity.addObject(null, null, getResourceURL());
		return activity;
	}
	
	/* (non-Javadoc)
	 * @see uk.ac.bolton.spaws.model.impl.ISubmission#getAction()
	 */
	public IParadata getAction() {
		return action;
	}
	/* (non-Javadoc)
	 * @see uk.ac.bolton.spaws.model.impl.ISubmission#setAction(uk.ac.bolton.spaws.model.IParadata)
	 */
	public void setAction(IParadata action) {
		this.action = action;
	}
	/* (non-Javadoc)
	 * @see uk.ac.bolton.spaws.model.impl.ISubmission#getActor()
	 */
	public IActor getActor() {
		return actor;
	}
	/* (non-Javadoc)
	 * @see uk.ac.bolton.spaws.model.impl.ISubmission#setActor(uk.ac.bolton.spaws.model.IActor)
	 */
	public void setActor(IActor actor) {
		this.actor = actor;
	}
	/* (non-Javadoc)
	 * @see uk.ac.bolton.spaws.model.impl.ISubmission#getResourceURL()
	 */
	public String getResourceURL() {
		return resourceURL;
	}
	/* (non-Javadoc)
	 * @see uk.ac.bolton.spaws.model.impl.ISubmission#setResourceURL(java.lang.String)
	 */
	public void setResourceURL(String resourceURL) {
		this.resourceURL = resourceURL;
	}

	public void setSubmitter(ISubmitter submitter) {
		this.submitter = submitter;
	}

	public ISubmitter getSubmitter() {
		return submitter;
	}
	
	/* (non-Javadoc)
	 * @see uk.ac.bolton.spaws.model.ISubmission#getUpdated()
	 */
	public Date getUpdated() {
		return updated;
	}

	/* (non-Javadoc)
	 * @see uk.ac.bolton.spaws.model.ISubmission#setUpdated(java.util.Date)
	 */
	public void setUpdated(Date submitted) {
		this.updated = submitted;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object other) {
		
		//
		// We're overriding equals for submissions in that if its the same actor using the same verb for the same
		// resource then its a duplicate.
		//
		if ( this.getActor().getName().equals( ((ISubmission)other).getActor().getName()) ){
			if ( this.getAction().getVerb().equals( ((ISubmission)other).getAction().getVerb())){
				if ( this.getResourceURL().equals( ((ISubmission)other).getResourceURL())){
					return true;
				}
			}
		}
		return false;
	}

}
<commit_msg>Update submission filter rules, so that same submitter is a requirement for a match, and also allow null for actor<commit_after>/*
 *  (c) 2012 University of Bolton
 *  
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 * limitations under the License.
 */
package uk.ac.bolton.spaws.model.impl;

import java.util.Date;

import com.navnorth.learningregistry.LRActivity;

import uk.ac.bolton.spaws.model.IActor;
import uk.ac.bolton.spaws.model.IParadata;
import uk.ac.bolton.spaws.model.ISubmission;
import uk.ac.bolton.spaws.model.ISubmitter;

public class Submission implements ISubmission {

	private ISubmitter submitter;
	private String resourceURL;
	private IParadata action;
	private IActor actor;
	private Date updated;
	
	public Submission(){
	}
	
	public Submission(Actor actor, IParadata action, String resourceUrl){
		setActor(actor);
		setAction(action);
		setResourceURL(resourceUrl);
		setSubmitter(new Submitter());
	}
	
	public Submission(ISubmitter submitter, Actor actor, IParadata action, String resourceUrl){
		setActor(actor);
		setAction(action);
		setResourceURL(resourceUrl);
		setSubmitter(submitter);
	}
	
	public Submission(ISubmitter submitter, Actor actor, IParadata action, String resourceUrl, Date updated){
		setActor(actor);
		setAction(action);
		setResourceURL(resourceUrl);
		setSubmitter(submitter);
		setUpdated(updated);
	}

	/* (non-Javadoc)
	 * @see uk.ac.bolton.spaws.model.impl.ISubmission#getActivity()
	 */
	public LRActivity getActivity(){
		LRActivity activity = new LRActivity(getResourceURL(), getSubmitter().getSubmitter(), getSubmitter().getSubmitterType(), getSubmitter().getSubmissionTOS(), getSubmitter().getSubmissionAttribution(), getSubmitter().getSigner());
		if (getActor() != null)
			activity.addActor("actor", getActor().getName(), getActor().getUrl(), null);
		activity.addVerb(getAction().getVerb(), null, null, null, null);
		if (this.action.getContextUrl() != null){
			activity.addContextToVerb("Widget", this.action.getContextUrl(), "Detail page");
		}
		activity.addContent(getAction().getContent());
		getAction().addMeasure(activity);
		activity.addObject(null, null, getResourceURL());
		return activity;
	}
	
	/* (non-Javadoc)
	 * @see uk.ac.bolton.spaws.model.impl.ISubmission#getAction()
	 */
	public IParadata getAction() {
		return action;
	}
	/* (non-Javadoc)
	 * @see uk.ac.bolton.spaws.model.impl.ISubmission#setAction(uk.ac.bolton.spaws.model.IParadata)
	 */
	public void setAction(IParadata action) {
		this.action = action;
	}
	/* (non-Javadoc)
	 * @see uk.ac.bolton.spaws.model.impl.ISubmission#getActor()
	 */
	public IActor getActor() {
		return actor;
	}
	/* (non-Javadoc)
	 * @see uk.ac.bolton.spaws.model.impl.ISubmission#setActor(uk.ac.bolton.spaws.model.IActor)
	 */
	public void setActor(IActor actor) {
		this.actor = actor;
	}
	/* (non-Javadoc)
	 * @see uk.ac.bolton.spaws.model.impl.ISubmission#getResourceURL()
	 */
	public String getResourceURL() {
		return resourceURL;
	}
	/* (non-Javadoc)
	 * @see uk.ac.bolton.spaws.model.impl.ISubmission#setResourceURL(java.lang.String)
	 */
	public void setResourceURL(String resourceURL) {
		this.resourceURL = resourceURL;
	}

	public void setSubmitter(ISubmitter submitter) {
		this.submitter = submitter;
	}

	public ISubmitter getSubmitter() {
		return submitter;
	}
	
	/* (non-Javadoc)
	 * @see uk.ac.bolton.spaws.model.ISubmission#getUpdated()
	 */
	public Date getUpdated() {
		return updated;
	}

	/* (non-Javadoc)
	 * @see uk.ac.bolton.spaws.model.ISubmission#setUpdated(java.util.Date)
	 */
	public void setUpdated(Date submitted) {
		this.updated = submitted;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object other) {
		
		//
		// We're overriding equals for submissions in that if its the same actor using the same verb for the same
		// resource, and was submitted using the same submitter,then its a duplicate.
		//
		if (this.getSubmitter().getSubmitter().equals(((ISubmission)other).getSubmitter().getSubmitter())){
			if ( this.getActor() == null && ((ISubmission)other).getActor() == null || this.getActor().getName().equals( ((ISubmission)other).getActor().getName())  ){
				if ( this.getAction().getVerb().equals( ((ISubmission)other).getAction().getVerb())){
					if ( this.getResourceURL().equals( ((ISubmission)other).getResourceURL())){
						return true;
					}
				}
			}
		}
		return false;
	}

}

{'fraction_non_alphanumeric': 0.133621143519006, 'fraction_numerical': 0.0016847425502790356, 'mean_word_length': 4.378255945639864, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '529830', 'n_tokens_mistral': 3348, 'n_tokens_neox': 3096, 'n_words': 683}