/******************************************************************************* * ALMA - Atacama Large Millimeter Array * Copyright (c) ESO - European Southern Observatory, 2012 * (in the framework of the ALMA collaboration). * All rights reserved. * * This library 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 2.1 of the License, or (at your option) any later version. * * This library 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 this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *******************************************************************************/ package alma.acs.commandcenter.serviceshelper; import java.util.ArrayList; import java.util.Collection; import java.util.List; import org.hibernate.HibernateException; import org.hibernate.Query; import org.hibernate.Session; import alma.acs.logging.AcsLogLevel; import alma.acs.logging.AcsLogger; import alma.acs.tmcdb.AcsServiceServiceType; /** * Objects of this class help retireving the list of services to start. *
* The list of services is read from the TMCDB for the passed configuration. * To rad the TMCDB, Hibernate is used by passing the SQL statement {@link #sqlQuery} * with a nemed parameter ({@link #namedParameterName}). *
* The services to start are returned as a list of {@link AcsServiceToStart}. *
* Considering that the query is in SQL format and the result of the query is a
* list of values from columns of different objects, we could as well used directly JDBC.
*
* @author acaproni
*/
class TMCDBServicesHelper {
/**
* A class to encapsulate the services to start
*
* @author acaproni
*
*/
public static class AcsServiceToStart {
/**
* The name of the service to start (can be null
)
*/
public final String serviceName;
/**
* The type of the service
*/
public final AcsServiceServiceType serviceType;
/**
* The host where the service must be started
*/
public final String hostName;
/**
* C'tor
*/
private AcsServiceToStart(String name, AcsServiceServiceType type, String host) {
this.serviceName=name;
this.serviceType=type;
this.hostName=host;
}
/**
* Return a {@link AcsServiceToStart} for a row returned by the query.
*
* The query executed in {@link TMCDBServicesHelper#getServicesList(String)} * returns a array of {@link Object}. The order of the columns is defined in the * select and must be the same used to create this object i.e. *
null
and not empty name of the configuration
* @return The not null
list of services to start for the passed configuration
* @throws HibernateException In case of error getting data from the TMCDB
*/
@SuppressWarnings("rawtypes")
public List