public class CableService extends Object
CableService is the service layer that handles individual cable
operations.| Constructor and Description |
|---|
CableService() |
| Modifier and Type | Method and Description |
|---|---|
List<String> |
cablesByName(String namePart,
int limit)
Helps listing cable names for UI autocomplete method.
|
Cable |
createCable(CableParams newCable)
Creates a cable in the database and returns it.
|
List<Cable> |
createCables(Iterable<Cable> cables,
String userId,
boolean sendNotification)
Creates a bunch of cables in the database and returns them.
|
boolean |
deleteCable(Cable cable,
String userId)
Marks the cable deleted in the database.
|
int |
deleteCables(Iterable<Cable> cables,
String userId)
Marks the cables deleted in the database.
|
protected String |
escapeDbString(String dbString)
Escapes the characters that have a special meaning in the database LIKE
query, '%' and '_'.
|
protected String |
escapeDbStringRegexlike(String dbString)
Escapes the characters that have a special meaning in the database LIKE
query, '%' and '_'.
|
boolean |
getAndFbsTagUpdateCables(int start,
int size,
String userId,
Map<String,FbsElement> mappingsCableNameToFbsElement,
Map<String,FbsElement> mappingsEssNameToFbsElement,
Map<String,FbsElement> mappingsIdToFbsElement,
Map<String,FbsElement> mappingsTagToFbsElement,
Map<String,List<NotificationDTO>> mapOwnersCablesUnexpectedChanges)
Retrieves cables and updates FBS tag mappings in one transaction to ensure no other
changes happen in the mean time.
|
boolean |
getAndValidateCables(int start,
int size,
String userId)
Retrieves cables and validates them in one transaction to ensure no other
changes happen in the mean time.
|
Cable |
getCableById(Long id)
Returns a cable with the specified cable id.
|
Cable |
getCableByName(String name)
Returns a cable with the specified cable name.
|
Cable |
getCableByName(String name,
Boolean detached)
Returns a cable with the specified cable name.
|
List<Cable> |
getCableEndpoints(Query customQuery)
Returns minimal data on cables
|
List<Cable> |
getCables() |
List<Cable> |
getCables(String system,
String subsystem)
Returns a list of cables associated with the specified parameters.
|
List<Cable> |
getCables(String system,
String subsystem,
String installationPackage)
Returns a list of cables associated with the specified parameters.
|
List<Cable> |
getCablesByName(Iterable<String> names,
Boolean detached,
boolean getDeleted)
Returns a list of cables with the specified names.
|
List<Cable> |
getFilteredCablesByRegExp(List<CableColumn> fields,
String regExp)
Returns a list of cables filtered by regural expression.
|
LazyService<Cable> |
getLazyService() |
long |
getRowCount(Map<String,Object> filters,
Query customQuery)
Returns the number of elements to be included in the table.
|
Cable |
reuseCable(ReuseCableDetails cableDetails)
Validates parameter, and reuses cable.
|
boolean |
updateCable(Cable cable,
Cable oldCable,
String userId,
boolean sendNotification)
Updates the attributes on the given cable.
|
int |
updateCables(Iterable<Cable> cables,
Iterable<Cable> oldCables,
String userId,
boolean sendNotification)
Updates the attributes on the given cables.
|
void |
updateFbsTagMappings(String userId,
Iterable<Cable> cables,
Map<String,FbsElement> mappingsCableNameToFbsElement,
Map<String,FbsElement> mappingsEssNameToFbsElement,
Map<String,FbsElement> mappingsIdToFbsElement,
Map<String,FbsElement> mappingsTagToFbsElement,
Map<String,List<NotificationDTO>> mapOwnersCablesUnexpectedChanges)
Update FBS tag mappings for cables.
|
void |
updateValidity(String userId,
Cable cable)
Updates the validity of the cable.
|
void |
validateCables(String userId,
Iterable<Cable> cables)
Validates the consistency of cable data and updates the data and/or status.
|
public LazyService<Cable> getLazyService()
public List<Cable> getFilteredCablesByRegExp(List<CableColumn> fields, String regExp)
fields - filter fieldsregExp - filter regular expressionpublic Cable getCableByName(String name, Boolean detached)
name - the cable name (example 12A012345)detached - boolean indicating if the cable should be detached from the
databasepublic Cable getCableByName(String name)
name - the cable name (example 12A012345)public List<Cable> getCables(String system, String subsystem)
Note:
system - systemsubsystem - subsystempublic List<Cable> getCables(String system, String subsystem, String installationPackage)
Note:
system - systemsubsystem - subsysteminstallationPackage - installation packagepublic List<Cable> getCablesByName(Iterable<String> names, Boolean detached, boolean getDeleted)
names - the cable namesdetached - a boolean indicating if the cables should be detached from the
databasegetDeleted - if true returns all cables, if false only non-deletedpublic List<String> cablesByName(String namePart, int limit)
namePart - the part of the cable name that has to be looked for in the DBlimit - size limit for the response listpublic Cable reuseCable(ReuseCableDetails cableDetails)
cableDetails - new value for cable that has to be re-usedRuntimeException - when cable name is empty; cable not found, or DB error happenedpublic Cable getCableById(Long id)
id - the cable idpublic List<Cable> createCables(Iterable<Cable> cables, String userId, boolean sendNotification)
cables - cables to create in databaseuserId - user creating cablessendNotification - boolean indicating if notification regarding cable status should
be sendpublic Cable createCable(CableParams newCable)
newCable - the parameters of the cable that has to be storedpublic int updateCables(Iterable<Cable> cables, Iterable<Cable> oldCables, String userId, boolean sendNotification)
cables - the cables with modified attributes to save to the database.oldCables - the cables before modification. Should be in the same order as in
cables. Also needs to be of the same size as cables.userId - username of user updating the cables, for history recordsendNotification - boolean indicating if notification regarding cable status should
be sendpublic boolean updateCable(Cable cable, Cable oldCable, String userId, boolean sendNotification)
cable - the cable with modified attributes to save to the databaseoldCable - the cable before modificationuserId - username of user updating the cable, for history recordsendNotification - boolean indicating if notification regarding cable status should
be sendpublic int deleteCables(Iterable<Cable> cables, String userId)
cables - the cables to deleteuserId - username of user deleting the cables, for history recordpublic boolean deleteCable(Cable cable, String userId)
cable - the cable to deleteuserId - username of user deleting the cable, for history recordpublic boolean getAndFbsTagUpdateCables(int start,
int size,
String userId,
Map<String,FbsElement> mappingsCableNameToFbsElement,
Map<String,FbsElement> mappingsEssNameToFbsElement,
Map<String,FbsElement> mappingsIdToFbsElement,
Map<String,FbsElement> mappingsTagToFbsElement,
Map<String,List<NotificationDTO>> mapOwnersCablesUnexpectedChanges)
start - the number of the starting cable to updatesize - amount of cables to updateuserId - id of the user invoking updatemappingsCableNameToFbsElement - mappings for cable name to FbsElementmappingsEssNameToFbsElement - mappings for ESS name to FbsElementmappingsIdToFbsElement - mappings for id to FbsElementmappingsTagToFbsElement - mappings for tag to FbsElementmapOwnersCablesUnexpectedChanges - map with key (ownersstring) and value (list of cable names)
to track cables for which values changed unexpectedly in tag mapping updategetAndValidateCables(int, int, String)public void updateFbsTagMappings(String userId, Iterable<Cable> cables, Map<String,FbsElement> mappingsCableNameToFbsElement, Map<String,FbsElement> mappingsEssNameToFbsElement, Map<String,FbsElement> mappingsIdToFbsElement, Map<String,FbsElement> mappingsTagToFbsElement, Map<String,List<NotificationDTO>> mapOwnersCablesUnexpectedChanges)
userId - id of the user invoking validationcables - cables to validatemappingsCableNameToFbsElement - mappings for cable name to FbsElementmappingsEssNameToFbsElement - mappings for ESS name to FbsElementmappingsIdToFbsElement - mappings for id to FbsElementmappingsTagToFbsElement - mappings for tag to FbsElementmapOwnersCablesUnexpectedChanges - map with key (ownersstring) and value (list of cable names)
to track cables for which values changed unexpectedly in tag mapping updatepublic boolean getAndValidateCables(int start,
int size,
String userId)
start - the number of the starting cable to validatesize - amount of cables to validateuserId - username of the user invoking validationpublic void validateCables(String userId, Iterable<Cable> cables)
userId - id of the user invoking validationcables - the cables to validatepublic void updateValidity(String userId, Cable cable)
userId - id of the user invoking validationcable - the cable to validatepublic List<Cable> getCableEndpoints(Query customQuery)
customQuery - customQuery for filteringprotected String escapeDbString(String dbString)
dbString - the string to escapeprotected String escapeDbStringRegexlike(String dbString)
dbString - the string to escapeCopyright © 2025 European Spallation Source. All rights reserved.