/*
* Copyright (C) 2005-2011 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see .
*/
package org.alfresco.repo.domain.solr;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.alfresco.repo.domain.qname.QNameDAO;
import org.alfresco.repo.solr.NodeParameters;
/**
* Stores node query parameters for use in SOLR DAO queries
*
* @since 4.0
*/
public class NodeParametersEntity extends NodeParameters
{
private List includeTypeIds;
private List excludeTypeIds;
private List includeAspectIds;
private List excludeAspectIds;
/**
* Public constructor, but not generally useful
*/
public NodeParametersEntity()
{
}
/**
* Construct from higher-level parameters
*/
public NodeParametersEntity(NodeParameters params, QNameDAO qnameDAO)
{
this.setFromNodeId(params.getFromNodeId());
this.setToNodeId(params.getToNodeId());
this.setFromTxnId(params.getFromTxnId());
this.setToTxnId(params.getToTxnId());
this.setTransactionIds(params.getTransactionIds());
this.setStoreIdentifier(params.getStoreIdentifier());
this.setStoreProtocol(params.getStoreProtocol());
// Translate the QNames, if provided
if (params.getIncludeNodeTypes() != null)
{
Set qnamesIds = qnameDAO.convertQNamesToIds(params.getIncludeNodeTypes(), false);
this.setIncludeTypeIds(new ArrayList(qnamesIds));
}
if (params.getExcludeNodeTypes() != null)
{
Set qnamesIds = qnameDAO.convertQNamesToIds(params.getExcludeNodeTypes(), false);
this.setExcludeTypeIds(new ArrayList(qnamesIds));
}
if (params.getExcludeAspects() != null)
{
Set qnamesIds = qnameDAO.convertQNamesToIds(params.getExcludeAspects(), false);
this.setExcludeAspectIds(new ArrayList(qnamesIds));
}
if (params.getIncludeAspects() != null)
{
Set qnamesIds = qnameDAO.convertQNamesToIds(params.getIncludeAspects(), false);
this.setIncludeAspectIds(new ArrayList(qnamesIds));
}
}
public boolean getStoreFilter()
{
return (getStoreProtocol() != null || getStoreIdentifier() != null);
}
public List getIncludeAspectIds()
{
return includeAspectIds;
}
public void setIncludeAspectIds(List includeAspectIds)
{
this.includeAspectIds = includeAspectIds;
}
public List getExcludeAspectIds()
{
return excludeAspectIds;
}
public void setExcludeAspectIds(List excludeAspectIds)
{
this.excludeAspectIds = excludeAspectIds;
}
public List getIncludeTypeIds()
{
return includeTypeIds;
}
public void setIncludeTypeIds(List includeTypeIds)
{
this.includeTypeIds = includeTypeIds;
}
public List getExcludeTypeIds()
{
return excludeTypeIds;
}
public void setExcludeTypeIds(List excludeTypeIds)
{
this.excludeTypeIds = excludeTypeIds;
}
public boolean isIncludeNodesTable()
{
return (getFromNodeId() != null || getToNodeId() != null || getIncludeTypeIds() != null || getExcludeTypeIds() != null || getIncludeAspectIds() != null || getExcludeAspectIds() != null);
}
}