Class LocalFileKnowledgeBase
java.lang.Object
com.sonyericsson.jenkins.plugins.bfa.db.KnowledgeBase
com.sonyericsson.jenkins.plugins.bfa.db.LocalFileKnowledgeBase
- All Implemented Interfaces:
Describable<KnowledgeBase>,Serializable
Handling of the list the traditional way. Local in memory and serialized with the object.
- Author:
- Robert Sandell <robert.sandell@sonyericsson.com>
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class com.sonyericsson.jenkins.plugins.bfa.db.KnowledgeBase
KnowledgeBase.KnowledgeBaseDescriptor -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.LocalFileKnowledgeBase(CopyOnWriteList<FailureCause> legacyCauses) Standard constructor.LocalFileKnowledgeBase(Collection<FailureCause> initialCauses) Standard constructor. -
Method Summary
Modifier and TypeMethodDescriptionaddCause(FailureCause cause) Saves a new cause to the db and generates a new id for the cause.voidconvertFrom(KnowledgeBase oldKnowledgeBase) Converts the existing old knowledge base into this one.booleanequals(KnowledgeBase oldKnowledgeBase) Called to see if the configuration has changed.booleanGets the unique categories of all FailureCauses.Get the cause with the given id.Get the list of theFailureCause's names and ids.Get the list ofFailureCauses.Get a shallow list of theFailureCauses.inthashCode()booleanIf Statistics logging is enabled on this knowledge base or not.booleanIf all builds should be added to statistics logging, not just unsuccessful builds.protected voidput(FailureCause cause) Puts the cause directly into the map.voidremoveBuildfailurecause(Run build) Removes the build failure cause of particular build.removeCause(String id) Removes the cause from the knowledge base.saveCause(FailureCause cause) Saves a cause to the db.voidsaveStatistics(Statistics stat) Saves the Statistics.voidstart()Called when the KnowledgeBase should be up and running.voidstop()Called when it is time to clean up after the KnowledgeBase.Methods inherited from class com.sonyericsson.jenkins.plugins.bfa.db.KnowledgeBase
convertFromAbstract, getCreationDateForCause, getLatestFailureForCause, removeBuildfailurecause, updateLastSeen
-
Constructor Details
-
LocalFileKnowledgeBase
Standard constructor. Used for legacy conversion.- Parameters:
legacyCauses- the causes.
-
LocalFileKnowledgeBase
Standard constructor. Used for simple testability.- Parameters:
initialCauses- the causes.
-
LocalFileKnowledgeBase
@DataBoundConstructor public LocalFileKnowledgeBase()Default constructor.
-
-
Method Details
-
getCauses
Description copied from class:KnowledgeBaseGet the list ofFailureCauses. It is intended to be used in the scanning phase hence it should be returned as quickly as possible, so the list could be cached.- Specified by:
getCausesin classKnowledgeBase- Returns:
- the full list of causes.
-
getCauseNames
Description copied from class:KnowledgeBaseGet the list of theFailureCause's names and ids. The list should be the latest possible from the DB as they will be used for editing. The objects returned should contain at least the id and the name of the cause.- Specified by:
getCauseNamesin classKnowledgeBase- Returns:
- the full list of the names and ids of the causes.
-
getShallowCauses
Description copied from class:KnowledgeBaseGet a shallow list of theFailureCauses. The list should be the latest possible from the DB as they will be used in the list of causes to edit. shallow meaning no indications but information enough to show a nice list; at least id and name but description, comment, lastOccurred and categories are preferred as well.- Specified by:
getShallowCausesin classKnowledgeBase- Returns:
- a shallow list of all causes.
- Throws:
Exception- if something in the KnowledgeBase handling goes wrong.- See Also:
-
getCause
Description copied from class:KnowledgeBaseGet the cause with the given id. The cause returned is intended to be edited right away, so it should be as fresh from the db as possible.- Specified by:
getCausein classKnowledgeBase- Parameters:
id- the id of the cause.- Returns:
- the cause or null if a cause with that id could not be found.
-
addCause
Description copied from class:KnowledgeBaseSaves a new cause to the db and generates a new id for the cause.- Specified by:
addCausein classKnowledgeBase- Parameters:
cause- the cause to add.- Returns:
- the same cause but with a new id.
- Throws:
IOException
-
removeCause
Description copied from class:KnowledgeBaseRemoves the cause from the knowledge base.- Specified by:
removeCausein classKnowledgeBase- Parameters:
id- the id of the cause to remove.- Returns:
- the removed FailureCause.
- Throws:
Exception- if so.
-
saveCause
Description copied from class:KnowledgeBaseSaves a cause to the db. Assumes that the id is kept from when it was fetched. Can also be an existing cause in anotherKnowledgeBaseimplementation with a preexisting id that is being converted viaKnowledgeBase.convertFrom(KnowledgeBase).- Specified by:
saveCausein classKnowledgeBase- Parameters:
cause- the cause to add.- Returns:
- the same cause but with a new id.
- Throws:
IOException
-
put
Puts the cause directly into the map. Does not call save.- Parameters:
cause- the cause to put.
-
convertFrom
Description copied from class:KnowledgeBaseConverts the existing old knowledge base into this one. Will be called after the creation of a new object when then Jenkins config is saved, So it could just be that the old one is exactly the same as this one.- Specified by:
convertFromin classKnowledgeBase- Parameters:
oldKnowledgeBase- the old one.- Throws:
Exception- if something in the KnowledgeBase handling goes wrong.
-
getCategories
Description copied from class:KnowledgeBaseGets the unique categories of all FailureCauses.- Specified by:
getCategoriesin classKnowledgeBase- Returns:
- the list of categories.
- Throws:
Exception- if something in the KnowledgeBase handling goes wrong.
-
equals
Description copied from class:KnowledgeBaseCalled to see if the configuration has changed.- Specified by:
equalsin classKnowledgeBase- Parameters:
oldKnowledgeBase- the previous config.- Returns:
- true if it is the same.
-
start
public void start()Description copied from class:KnowledgeBaseCalled when the KnowledgeBase should be up and running.- Specified by:
startin classKnowledgeBase
-
stop
public void stop()Description copied from class:KnowledgeBaseCalled when it is time to clean up after the KnowledgeBase.- Specified by:
stopin classKnowledgeBase
-
equals
-
hashCode
public int hashCode() -
isEnableStatistics
public boolean isEnableStatistics()Description copied from class:KnowledgeBaseIf Statistics logging is enabled on this knowledge base or not.- Specified by:
isEnableStatisticsin classKnowledgeBase- Returns:
- true if so. False if not or not implemented.
-
isSuccessfulLogging
public boolean isSuccessfulLogging()Description copied from class:KnowledgeBaseIf all builds should be added to statistics logging, not just unsuccessful builds. Only relevant ifKnowledgeBase.isEnableStatistics()is true.- Specified by:
isSuccessfulLoggingin classKnowledgeBase- Returns:
- true if set, false otherwise or if not implemented
-
saveStatistics
Description copied from class:KnowledgeBaseSaves the Statistics.- Specified by:
saveStatisticsin classKnowledgeBase- Parameters:
stat- the Statistics.- Throws:
Exception- if something in the KnowledgeBase handling goes wrong.
-
getDescriptor
-
removeBuildfailurecause
Description copied from class:KnowledgeBaseRemoves the build failure cause of particular build.- Overrides:
removeBuildfailurecausein classKnowledgeBase- Parameters:
build- the build.- Throws:
Exception- if something in the KnowledgeBase handling goes wrong.
-