com.sonyericsson.jenkins.plugins.bfa.db
Class LocalFileKnowledgeBase

java.lang.Object
  extended by com.sonyericsson.jenkins.plugins.bfa.db.KnowledgeBase
      extended by com.sonyericsson.jenkins.plugins.bfa.db.LocalFileKnowledgeBase
All Implemented Interfaces:
hudson.model.Describable<KnowledgeBase>, Serializable

public class LocalFileKnowledgeBase
extends KnowledgeBase

Handling of the list the traditional way. Local in memory and serialized with the object.

Author:
Robert Sandell <robert.sandell@sonyericsson.com>
See Also:
Serialized Form

Nested Class Summary
static class LocalFileKnowledgeBase.LocalFileKnowledgeBaseDescriptor
          Descriptor for LocalFileKnowledgeBase.
 
Nested classes/interfaces inherited from class com.sonyericsson.jenkins.plugins.bfa.db.KnowledgeBase
KnowledgeBase.KnowledgeBaseDescriptor
 
Constructor Summary
LocalFileKnowledgeBase()
          Default constructor.
LocalFileKnowledgeBase(Collection<FailureCause> initialCauses)
          Standard constructor.
LocalFileKnowledgeBase(hudson.util.CopyOnWriteList<FailureCause> legacyCauses)
          Standard constructor.
 
Method Summary
 FailureCause addCause(FailureCause cause)
          Saves a new cause to the db and generates a new id for the cause.
 void convertFrom(KnowledgeBase oldKnowledgeBase)
          Converts the existing old knowledge base into this one.
 boolean equals(KnowledgeBase oldKnowledgeBase)
          Called to see if the configuration has changed.
 boolean equals(Object other)
           
 List<String> getCategories()
          Gets the unique categories of all FailureCauses.
 FailureCause getCause(String id)
          Get the cause with the given id.
 Collection<FailureCause> getCauseNames()
          Get the list of the FailureCause's names and ids.
 Collection<FailureCause> getCauses()
          Get the list of FailureCauses.
 hudson.model.Descriptor<KnowledgeBase> getDescriptor()
           
 Collection<FailureCause> getShallowCauses()
          Get a shallow list of the FailureCauses.
 int hashCode()
           
 boolean isStatisticsEnabled()
          If Statistics logging is enabled on this knowledge base or not.
 boolean isSuccessfulLoggingEnabled()
          If all builds should be added to statistics logging, not just unsuccessful builds.
protected  void put(FailureCause cause)
          Puts the cause directly into the map.
 void removeBuildfailurecause(hudson.model.AbstractBuild build)
          Removes the build failure cause of particular build.
 FailureCause removeCause(String id)
          Removes the cause from the knowledge base.
 FailureCause saveCause(FailureCause cause)
          Saves a cause to the db.
 void saveStatistics(Statistics stat)
          Saves the Statistics.
 void start()
          Called when the KnowledgeBase should be up and running.
 void stop()
          Called when it is time to clean up after the KnowledgeBase.
 
Methods inherited from class com.sonyericsson.jenkins.plugins.bfa.db.KnowledgeBase
convertFromAbstract, getFailureCauseNames, getFailureCausesPerBuild, getFailureCausesPerTime, getNbrOfFailureCategoriesPerName, getNbrOfFailureCauses, getNbrOfFailureCausesPerId, getNbrOfNullFailureCauses, getStatistics, getUnknownFailureCauseQuotaPerTime
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalFileKnowledgeBase

public LocalFileKnowledgeBase(hudson.util.CopyOnWriteList<FailureCause> legacyCauses)
Standard constructor. Used for legacy conversion.

Parameters:
legacyCauses - the causes.

LocalFileKnowledgeBase

public LocalFileKnowledgeBase(Collection<FailureCause> initialCauses)
Standard constructor. Used for simple testability.

Parameters:
initialCauses - the causes.

LocalFileKnowledgeBase

@DataBoundConstructor
public LocalFileKnowledgeBase()
Default constructor.

Method Detail

getCauses

public Collection<FailureCause> getCauses()
Description copied from class: KnowledgeBase
Get the list of FailureCauses. 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:
getCauses in class KnowledgeBase
Returns:
the full list of causes.

getCauseNames

public Collection<FailureCause> getCauseNames()
Description copied from class: KnowledgeBase
Get the list of the FailureCause'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:
getCauseNames in class KnowledgeBase
Returns:
the full list of the names and ids of the causes.

getShallowCauses

public Collection<FailureCause> getShallowCauses()
                                          throws Exception
Description copied from class: KnowledgeBase
Get a shallow list of the FailureCauses. 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 and categories are preferred as well.

Specified by:
getShallowCauses in class KnowledgeBase
Returns:
a shallow list of all causes.
Throws:
Exception - if something in the KnowledgeBase handling goes wrong.
See Also:
KnowledgeBase.getCauseNames()

getCause

public FailureCause getCause(String id)
Description copied from class: KnowledgeBase
Get 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:
getCause in class KnowledgeBase
Parameters:
id - the id of the cause.
Returns:
the cause or null if a cause with that id could not be found.

addCause

public FailureCause addCause(FailureCause cause)
                      throws IOException
Description copied from class: KnowledgeBase
Saves a new cause to the db and generates a new id for the cause.

Specified by:
addCause in class KnowledgeBase
Parameters:
cause - the cause to add.
Returns:
the same cause but with a new id.
Throws:
IOException

removeCause

public FailureCause removeCause(String id)
                         throws Exception
Description copied from class: KnowledgeBase
Removes the cause from the knowledge base.

Specified by:
removeCause in class KnowledgeBase
Parameters:
id - the id of the cause to remove.
Returns:
the removed FailureCause.
Throws:
Exception - if so.

saveCause

public FailureCause saveCause(FailureCause cause)
                       throws IOException
Description copied from class: KnowledgeBase
Saves a cause to the db. Assumes that the id is kept from when it was fetched. Can also be an existing cause in another KnowledgeBase implementation with a preexisting id that is being converted via KnowledgeBase.convertFrom(KnowledgeBase).

Specified by:
saveCause in class KnowledgeBase
Parameters:
cause - the cause to add.
Returns:
the same cause but with a new id.
Throws:
IOException

put

protected void put(FailureCause cause)
Puts the cause directly into the map. Does not call save.

Parameters:
cause - the cause to put.

convertFrom

public void convertFrom(KnowledgeBase oldKnowledgeBase)
                 throws Exception
Description copied from class: KnowledgeBase
Converts 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:
convertFrom in class KnowledgeBase
Parameters:
oldKnowledgeBase - the old one.
Throws:
Exception - if something in the KnowledgeBase handling goes wrong.

getCategories

public List<String> getCategories()
                           throws Exception
Description copied from class: KnowledgeBase
Gets the unique categories of all FailureCauses.

Specified by:
getCategories in class KnowledgeBase
Returns:
the list of categories.
Throws:
Exception - if something in the KnowledgeBase handling goes wrong.

equals

public boolean equals(KnowledgeBase oldKnowledgeBase)
Description copied from class: KnowledgeBase
Called to see if the configuration has changed.

Specified by:
equals in class KnowledgeBase
Parameters:
oldKnowledgeBase - the previous config.
Returns:
true if it is the same.

start

public void start()
Description copied from class: KnowledgeBase
Called when the KnowledgeBase should be up and running.

Specified by:
start in class KnowledgeBase

stop

public void stop()
Description copied from class: KnowledgeBase
Called when it is time to clean up after the KnowledgeBase.

Specified by:
stop in class KnowledgeBase

equals

public boolean equals(Object other)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class KnowledgeBase

isStatisticsEnabled

public boolean isStatisticsEnabled()
Description copied from class: KnowledgeBase
If Statistics logging is enabled on this knowledge base or not.

Specified by:
isStatisticsEnabled in class KnowledgeBase
Returns:
true if so. False if not or not implemented.

isSuccessfulLoggingEnabled

public boolean isSuccessfulLoggingEnabled()
Description copied from class: KnowledgeBase
If all builds should be added to statistics logging, not just unsuccessful builds. Only relevant if KnowledgeBase.isStatisticsEnabled() is true.

Specified by:
isSuccessfulLoggingEnabled in class KnowledgeBase
Returns:
true if set, false otherwise or if not implemented

saveStatistics

public void saveStatistics(Statistics stat)
                    throws Exception
Description copied from class: KnowledgeBase
Saves the Statistics.

Specified by:
saveStatistics in class KnowledgeBase
Parameters:
stat - the Statistics.
Throws:
Exception - if something in the KnowledgeBase handling goes wrong.

getDescriptor

public hudson.model.Descriptor<KnowledgeBase> getDescriptor()

removeBuildfailurecause

public void removeBuildfailurecause(hudson.model.AbstractBuild build)
                             throws Exception
Description copied from class: KnowledgeBase
Removes the build failure cause of particular build.

Specified by:
removeBuildfailurecause in class KnowledgeBase
Parameters:
build - the AbstractBuild.
Throws:
Exception - if something in the KnowledgeBase handling goes wrong.


Copyright © 2004-2014. All Rights Reserved.