openlsd.database.data
Class LSDDbService

java.lang.Object
  extended by openlsd.database.data.LSDDbService

public class LSDDbService
extends java.lang.Object

Class for Service manipulation

Author:
Frederic Bregier LGPL

Field Summary
static java.lang.String allfields
          DB field for all fields in select command.
static java.lang.String[] fields
          DB field names
 long idip
          IpPort Id
 long idservice
          Service Id
static int ridip
          DB field rank
static int ridservice
          DB field rank
static int rstatus
          DB field rank
 int status
          Status of this Instance of Service
static java.lang.String table
          information for DB manipulation: Table name
 
Constructor Summary
LSDDbService()
          Create an empty Service
LSDDbService(long idservice, long idip, int status)
          Create a Service from args
 
Method Summary
static boolean del(LSDDbAdmin admin, long idservice)
          Del all Services object from the DB associated with the idservice
static int del(LSDDbAdmin admin, long idservice, long idip)
          Del the Service object from the DB associated with the idservice and idip
static long findFirstIndex(LSDDbAdmin admin)
          Find first available Service id for this object.
 boolean get(java.sql.ResultSet resultSet)
          Get Values from ResultSet
 boolean getId(java.sql.ResultSet resultSet)
          Get Only Id from ResultSet
static java.util.ArrayList<LSDDbService> getServices(LSDDbAdmin admin, long idservice)
          Get all Services associated to idservice from DB
static java.util.ArrayList<LSDDbService> newService(LSDDbAdmin admin, java.util.ArrayList<LSDDbIpPort> listIpPort, long idService)
          Create a new Service List from the List of IpPort for the same Service.
 boolean set(LSDDbAdmin admin)
          Update or Insert if it does not exist.
 boolean set(LSDDbAdmin admin, int status)
          Update or Insert data into DB from object.
 java.lang.String toString()
          Object to String
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

idservice

public long idservice
Service Id


idip

public long idip
IpPort Id


status

public int status
Status of this Instance of Service


table

public static final java.lang.String table
information for DB manipulation: Table name

See Also:
Constant Field Values

fields

public static final java.lang.String[] fields
DB field names


ridservice

public static final int ridservice
DB field rank

See Also:
Constant Field Values

ridip

public static final int ridip
DB field rank

See Also:
Constant Field Values

rstatus

public static final int rstatus
DB field rank

See Also:
Constant Field Values

allfields

public static final java.lang.String allfields
DB field for all fields in select command.

Constructor Detail

LSDDbService

public LSDDbService()
Create an empty Service


LSDDbService

public LSDDbService(long idservice,
                    long idip,
                    int status)
Create a Service from args

Parameters:
idservice -
idip -
status -
Method Detail

get

public boolean get(java.sql.ResultSet resultSet)
Get Values from ResultSet

Parameters:
resultSet -
Returns:
True if OK, else False

getId

public boolean getId(java.sql.ResultSet resultSet)
Get Only Id from ResultSet

Parameters:
resultSet -
Returns:
True if OK, else False

set

public boolean set(LSDDbAdmin admin)
Update or Insert if it does not exist. IdService must be OK. This function should be used only for update.

Parameters:
admin -
Returns:
True if OK, else False

set

public boolean set(LSDDbAdmin admin,
                   int status)
Update or Insert data into DB from object. (id must be > invalide_idx) This function should be used only for update with a new status.

Parameters:
admin -
status -
Returns:
True if OK, else False

del

public static boolean del(LSDDbAdmin admin,
                          long idservice)
Del all Services object from the DB associated with the idservice

Parameters:
admin -
idservice -
Returns:
True if OK, else False

del

public static int del(LSDDbAdmin admin,
                      long idservice,
                      long idip)
Del the Service object from the DB associated with the idservice and idip

Parameters:
admin -
idservice -
idip -
Returns:
the number of rows deleted

newService

public static java.util.ArrayList<LSDDbService> newService(LSDDbAdmin admin,
                                                           java.util.ArrayList<LSDDbIpPort> listIpPort,
                                                           long idService)
Create a new Service List from the List of IpPort for the same Service. If the idService passed to the function is KO, try to create a new one (check the value of one of the Service to get this common value). All IpPort for the same service will have the same idService. The List listIpPort is not cleared after this call.

Parameters:
admin -
listIpPort -
idService -
Returns:
the list of Service created or if an error occurs null if no Service were added, or a sublist of services created

getServices

public static java.util.ArrayList<LSDDbService> getServices(LSDDbAdmin admin,
                                                            long idservice)
Get all Services associated to idservice from DB

Parameters:
admin -
idservice -
Returns:
the list of Services or null if an error occurs

findFirstIndex

public static long findFirstIndex(LSDDbAdmin admin)
Find first available Service id for this object. No update are made into the DB.

Parameters:
admin -
Returns:
The new index if found or LSDConstant.invalide_idx if not found.

toString

public java.lang.String toString()
Object to String

Overrides:
toString in class java.lang.Object
Returns:
the string that displays this object
See Also:
Object.toString()