All Downloads are FREE. Search and download functionalities are using the official Maven repository.

info.kwarc.sally4.mhw.base.impl.MathHubUserImpl Maven / Gradle / Ivy

The newest version!
package info.kwarc.sally4.mhw.base.impl;

import info.kwarc.sally4.mhw.base.IMathHubDocument;
import info.kwarc.sally4.mhw.base.IMathHubUser;
import info.kwarc.sally4.mhw.base.IMathHubWorker;

import java.util.Collection;
import java.util.HashSet;

import org.apache.felix.ipojo.annotations.Bind;
import org.apache.felix.ipojo.annotations.Component;
import org.apache.felix.ipojo.annotations.Property;
import org.apache.felix.ipojo.annotations.Provides;
import org.apache.felix.ipojo.annotations.Requires;
import org.apache.felix.ipojo.annotations.Unbind;

@Component(name=MathHubUserImpl.factory_id)
@Provides(specifications=IMathHubUser.class)
public class MathHubUserImpl implements IMathHubUser{
	final public static String factory_id = "info.kwarc.sally4.mhw.base.impl.MathHubUserImpl";
	
	@Property
	String name;

	@Property(mandatory=false)
	String privateKey;

	@Property
	String userId;
	
	
	@Requires(id = "mathHubWorkers", filter = "(filterThatWillNeverSucceed=1)", optional=true)
	IMathHubWorker[] mathHubWorker;
		
	public MathHubUserImpl(String name, String userId, String privateKey) {
		this.name = name;
		this.privateKey = privateKey;
		this.userId = userId;
	}
	
	public MathHubUserImpl() {
	}
	
	HashSet documents = new HashSet();
	
	@Bind(aggregate=true, optional=true, filter="(filterThatWillNeverSucceed=1)", id="userNewFilter")
	public void onNewDocument(IMathHubDocument mathHubDoc) {
		documents.add(mathHubDoc);
	}

	@Unbind(aggregate=true, optional=true, filter="(filterThatWillNeverSucceed=1)", id="userRemoveFilter")
	public void onRemoveDocument(IMathHubDocument mathHubDoc) {
		documents.remove(mathHubDoc);		
	}
	
	@Override
	public String getPrivateKey() {
		return privateKey;
	}
	
	@Override
	public String getUserName() {
		return name;
	}

	@Override
	public String getUserId() {
		return userId;
	}
	
	@Override
	public IMathHubWorker[] getAssignedWorkers() {
		return mathHubWorker;
	}

	@Override
	public Collection getOpenedDocuments() {
		return documents;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy