/**
 * Copyright 2008-2009 DRIVER PROJECT (Bielefeld University)
 * Original author: Marek Imialek <marek.imialek at uni-bielefeld.de>
 *
 * 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 eu.dnetlib.data.utility.featureextraction.dataprovider;

import java.util.List;
import java.util.UUID;

import javax.xml.ws.wsaddressing.W3CEndpointReference;

import eu.dnetlib.common.ws.dataprov.DataProviderProperties;
import eu.dnetlib.data.utility.featureextraction.Feature;
import eu.dnetlib.data.utility.featureextraction.IExtractionTaskProperties;
import eu.dnetlib.data.utility.featureextraction.dao.IResultDao;

/**
 * Data provider search properties.
 * 
 * @author jochen
 * @version
 */
public class FeatureExtractionDataProviderProperties extends DataProviderProperties implements IExtractionTaskProperties{

	/** The st id. */
	private String processId;

	/** The object types. */
	private List<String> objectTypes;

	/** The cache. */
	private IResultDao dao;		

	/** The total number of results. */
	private int totalNumberOfResults = -1;
	
	/** The input rs epr. */
	private W3CEndpointReference inputRsEpr;
	
	/** The feature. */
	private Feature feature;
	
	/** The exception. */
	private Throwable exception;

	/** The max package size for push rs. */
	private int maxPackageSizeForPushRS;
	
	/**
	 * Instantiates a new feature extraction data provider properties.
	 * 
	 * @param expiryTime the expiry time
	 */
	public FeatureExtractionDataProviderProperties(int expiryTime) {
		super(expiryTime);
		this.processId = generateBulkDataId();
	}
	
	/**
	 * Generate bulk data id.
	 * 
	 * @return the string
	 */
	private String generateBulkDataId() {
		return "bdid-" + UUID.randomUUID();
	}
	
	/**
	 * Gets the id.
	 * 
	 * @return the id
	 */
	public String getId() {
		return this.processId;
	}

	/**
	 * Sets the id.
	 * 
	 * @param processId the process id
	 */
	public void setId(String processId) {
		this.processId = processId;
	}

	/**
	 * Gets the object types.
	 * 
	 * @return the object types
	 */
	public List<String> getObjectTypes() {
		return this.objectTypes;
	}

	/**
	 * Sets the object types.
	 * 
	 * @param objectTypes the new object types
	 */
	public void setObjectTypes(List<String> objectTypes) {
		this.objectTypes = objectTypes;
	}

	/**
	 * Sets the total number of results.
	 * 
	 * @param totalNumberOfResults the new total number of results
	 */
	public void setTotalNumberOfResults(int totalNumberOfResults) {
		this.totalNumberOfResults = totalNumberOfResults;

	}

	/**
	 * Gets the total number of results.
	 * 
	 * @return the total number of results
	 */
	public int getTotalNumberOfResults() {
		return this.totalNumberOfResults;
	}

	/**
	 * Sets the input rs epr.
	 * 
	 * @param inputRsEpr the inputRsEpr to set
	 */
	public void setInputRsEpr(W3CEndpointReference inputRsEpr) {
		this.inputRsEpr = inputRsEpr;
	}

	/**
	 * Gets the input rs epr.
	 * 
	 * @return the inputRsEpr
	 */
	public W3CEndpointReference getInputRsEpr() {
		return inputRsEpr;
	}


	/* (non-Javadoc)
	 * @see eu.dnetlib.common.ws.dataprov.DataProviderProperties#getNumberOfCacheResults()
	 */
	@Override
	public int getNumberOfCacheResults() {
		if (dao != null)
			return this.dao.getNumberOfElements();
		else
			return 0;
	}

	/* (non-Javadoc)
	 * @see eu.dnetlib.common.ws.dataprov.DataProviderProperties#getType()
	 */
	@Override
	public Type getType() {
		// TODO Auto-generated method stub
		return null;
	}

	/**
	 * Sets the exception.
	 * 
	 * @param exception the exception to set
	 */
	public void setException(Throwable exception) {
		this.exception = exception;
	}

	/**
	 * Gets the exception.
	 * 
	 * @return the exception
	 */
	public Throwable getException() {
		return exception;
	}

	/**
	 * Sets the dao.
	 * 
	 * @param dao the dao to set
	 */
	public void setDao(IResultDao dao) {
		this.dao = dao;
	}

	/**
	 * Gets the dao.
	 * 
	 * @return the dao
	 */
	public IResultDao getDao() {
		return dao;
	}

	/* (non-Javadoc)
	 * @see eu.dnetlib.data.utility.featureextraction.IExtractionTaskProperties#getFeature()
	 */
	public Feature getFeature() {
		return feature;
	}

	/**
	 * Sets the feature.
	 * 
	 * @param feature the new feature
	 */
	public void setFeature(Feature feature) {
		this.feature = feature;
	}

	/**
	 * Sets the max package size for push rs.
	 * 
	 * @param maxPackageSizeForPushRS the new max package size for push rs
	 */
	public void setMaxPackageSizeForPushRS(int maxPackageSizeForPushRS) {
		this.maxPackageSizeForPushRS = maxPackageSizeForPushRS;		
	}
	
	/**
	 * Gets the max package size for push rs.
	 * 
	 * @return the max package size for push rs
	 */
	public int getMaxPackageSizeForPushRS() {
		return maxPackageSizeForPushRS;		
	}
}
