de.dfki.mycbr.core
Class Project

java.lang.Object
  extended by java.util.Observable
      extended by de.dfki.mycbr.core.model.Concept
          extended by de.dfki.mycbr.core.Project
All Implemented Interfaces:
IExplainable, java.util.Observer

public final class Project
extends Concept

A Project consists of a vocabulary and (possibly several) case bases. The vocabulary builds the model and consists of a concept hierarchy, the attribute descriptions of each concept and the corresponding similarity measures. It can be exported/imported via objects of classes that implement IImporter/ IExporter.

Author:
myCBR Team

Field Summary
static java.lang.String DEFAULT_FCT_NAME
          predefined constants for special values.
static java.lang.String DEFAULT_FCT_NAME_TMP
          predefined constants for special values.
static java.lang.String ID_DEFAULT
          predefined constants for special values.
static java.lang.String NO_SPECIAL_VALUE
          predefined constants for special values.
static java.lang.String UNDEFINED_SPECIAL_ATTRIBUTE
          predefined constants for special values.
static java.lang.String UNKNOWN_SPECIAL_VALUE
          predefined constants for special values.
 
Constructor Summary
Project()
          Default constructor.
Project(java.lang.String path)
          Constructor for project from file.
 
Method Summary
 void addAttributeDesc(AttributeDesc desc)
          Adds given description as attribute description to current c description.
 TaxonomyFct addInhFct(java.lang.String name)
          Creates a new InheritanceFct for myCBR's model.
 void addPartOfRelation(ConceptDesc desc)
          Adds desc as a part of relation of this concept.
 void addSpecialValue(java.lang.String value)
           
 Similarity calculateMultipleAttributeSimilarity(java.lang.Object simFct, MultipleAttribute<?> att1, MultipleAttribute<?> att2)
          Calculates the similarity of the given MultipleAttribute objects based on the given similarity function.
 Similarity calculateSpecialSimilarity(Attribute att1, Attribute att2)
          Calculates the similarity of the given attributes by calling the calculateSimilarity method of the appropriate similarity function.
 boolean canOverride(Concept c)
           
 void cleanInstances(Concept c, AttributeDesc desc)
          Cleans all instances known for concept c.
 DefaultCaseBase createDefaultCB(java.lang.String name)
          Tries to create a default case base for this project.
 DefaultCaseBase createDefaultCB(java.lang.String cbName, int currentCBCount)
          Used to speed up the import of case bases if the number of cases is known.
 Concept createTopConcept(java.lang.String id)
          Adds a new top c with the specified name to this project.
 void delete()
          Deletes the concept with the given ID from this model
 ICaseBase deleteCaseBase(java.lang.String name)
          Removes the case base specified by name from this project.
 void deletePartOfRelation(ConceptDesc desc)
          Removes the given description as part-of relation.
 java.util.HashMap<java.lang.String,AttributeDesc> getAllAttributeDescs()
          Gets the attribute descriptions of this c including inherited attributes.
 java.util.Collection<Instance> getAllInstances()
          Returns all instances that are known for this project.
 java.util.LinkedList<AttributeDesc> getAttDescsByName(java.lang.String name)
          Returns a list of attribute descriptions with the given name.
 java.util.HashMap<java.lang.String,AttributeDesc> getAttributeDescs()
          Gets the attribute descriptions of this c Be aware that the inherited attribute descriptions are not returned by this method.
 java.lang.String getAuthor()
          Gets the author of this project.
 java.util.HashMap<java.lang.String,ICaseBase> getCaseBases()
          Gets the case bases for this project.
 ICaseBase getCB(java.lang.String name)
          Returns the case base associated with the given name.
 Concept getConceptByID(java.lang.String id)
          Returns the c description with the given name.
 int getCurrentNumberOfCases()
          Returns the number of cases that have been imported so far.
 ExplanationManager getExplanationManager()
           
 java.lang.String getExtension()
          Returns the zip file's extension.
 TaxonomyFct getInhFct()
          Returns the inheritance function of this c.
 Instance getInstance(java.lang.String name)
          Returns the instance of this with name name and null if there is none.
 Similarity getLocalSimilarity(Attribute a, Attribute b, AttributeDesc desc)
          For displaying local similarities.
 java.util.Vector<ConceptDesc> getPartOfRelations()
          Returns all part-of relation known for this concept.
 java.lang.String getPath()
          Gets the path of this project.
 Project getProject()
          Returns the current project.
 Attribute getSpecialAttribute(java.lang.String obj)
          Returns the SpecialAttribute object corresponding to the given string.
 SymbolFct getSpecialFct()
          Returns the special function of this project.
 SpecialDesc getSpecialValueDesc()
           
 Concept getSuperConcept()
           
 int getTotalNumberOfCases()
          The total number of cases that have to be imported is given by this project's .myCBR file.
 boolean hasCB(java.lang.String name)
          Checks whether there is a case base with the given name.
 java.lang.Boolean hasConceptWithID(java.lang.String id)
          Checks whether there is a c description in the current inheritance hierarchy which has the specified name.
 boolean isImporting()
          Checks whether the import of this project is still running.
 boolean isSpecialAttribute(java.lang.String obj)
           
 boolean removeAttributeDesc(java.lang.String name)
          Removes the attribute given by name from the attributes of this c.
 void removeCase(java.lang.String name)
          Removes the case with the given name from each case base.
 Concept removeSubConcept(java.lang.String name)
          Removes the sub concept with name name.
 void save()
          Loads the project from the given file.
 void setAuthor(java.lang.String author)
          Sets the author of this project.
 void setInhFct(SpecialFct f)
          Changes the active special value function.
 void setPath(java.lang.String path)
          Sets the project's path to the specified path.
 void setSpecialValueFct(SpecialFct f)
          Changes the active special function.
 void setSuperConcept(Concept c, boolean isNEW)
          Moves this concept in the inheritance hierarchy.
 void update(java.util.Observable o, java.lang.Object arg)
           
 
Methods inherited from class de.dfki.mycbr.core.model.Concept
addAmalgamationFct, addInstance, addInstance, addSubConcept, copyInstance, deleteAmalgamFct, getActiveAmalgamFct, getAllSubConcepts, getAttributeDesc, getAttributesOfSubDescsForName, getAvailableAmalgamFcts, getDirectInstances, getExpType, getFct, getName, getQueryInstance, getSubConcepts, hasAttributeDesc, hasDirectAttributeDesc, removeInstance, renameAmalgamationFct, renameAttDesc, renameInstance, renameSubConcept, setActiveAmalgamFct, setAllInstancesMultiple, setAllInstancesSingle, setName
 
Methods inherited from class java.util.Observable
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNDEFINED_SPECIAL_ATTRIBUTE

public static final java.lang.String UNDEFINED_SPECIAL_ATTRIBUTE
predefined constants for special values. Should not be edited.

See Also:
Constant Field Values

UNKNOWN_SPECIAL_VALUE

public static final java.lang.String UNKNOWN_SPECIAL_VALUE
predefined constants for special values. Should not be edited.

See Also:
Constant Field Values

NO_SPECIAL_VALUE

public static final java.lang.String NO_SPECIAL_VALUE
predefined constants for special values. Should not be edited.

See Also:
Constant Field Values

DEFAULT_FCT_NAME

public static final java.lang.String DEFAULT_FCT_NAME
predefined constants for special values. Should not be edited.

See Also:
Constant Field Values

DEFAULT_FCT_NAME_TMP

public static final java.lang.String DEFAULT_FCT_NAME_TMP
predefined constants for special values. Should not be edited.

See Also:
Constant Field Values

ID_DEFAULT

public static final java.lang.String ID_DEFAULT
predefined constants for special values. Should not be edited.

See Also:
Constant Field Values
Constructor Detail

Project

public Project()
        throws java.lang.Exception
Default constructor. Initializes the containers for top concepts and case bases

Throws:
java.lang.Exception - never

Project

public Project(java.lang.String path)
        throws java.lang.Exception
Constructor for project from file. Either loads a _CBR_SMF.XML file or a .zip or .prj file. Initializes the containers for top concepts and case bases

Parameters:
path - the path to load the project from
Throws:
java.lang.Exception - never
Method Detail

isImporting

public boolean isImporting()
Checks whether the import of this project is still running.

Returns:
true, if importer is still running

getTotalNumberOfCases

public int getTotalNumberOfCases()
The total number of cases that have to be imported is given by this project's .myCBR file.

Returns:
the number of cases to be imported

getCurrentNumberOfCases

public int getCurrentNumberOfCases()
Returns the number of cases that have been imported so far.

Returns:
the number of cases imported so far

save

public void save()
Loads the project from the given file.


createDefaultCB

public DefaultCaseBase createDefaultCB(java.lang.String name)
                                throws java.lang.Exception
Tries to create a default case base for this project. Throws an exception if another case base with that name already exists.

Parameters:
name - the name of the new case base
Returns:
new default case base for this project.
Throws:
java.lang.Exception - if there is a case base with that name

hasCB

public boolean hasCB(java.lang.String name)
Checks whether there is a case base with the given name.

Parameters:
name - the name of the case base
Returns:
true if there is a case base with the given name

getCB

public ICaseBase getCB(java.lang.String name)
Returns the case base associated with the given name. Null if there is no case base with that name.

Parameters:
name - the name of the case base to be returned
Returns:
case base with name name or null if there is none

deleteCaseBase

public ICaseBase deleteCaseBase(java.lang.String name)
Removes the case base specified by name from this project.

Parameters:
name - the unique name of the case base to be removed
Returns:
the removed case base, null if none removed

getCaseBases

public java.util.HashMap<java.lang.String,ICaseBase> getCaseBases()
Gets the case bases for this project.

Returns:
the case bases for this project

createTopConcept

public Concept createTopConcept(java.lang.String id)
                         throws java.lang.Exception
Adds a new top c with the specified name to this project. Returns null if there is a c with this name contained in this project's c hierarchy.

Parameters:
id - the name for the new c
Returns:
new c attribute if name is unique, else null
Throws:
java.lang.Exception - if there is another concept with name id

getConceptByID

public Concept getConceptByID(java.lang.String id)
Returns the c description with the given name. Searches for a description in the whole model.

Parameters:
id - the ID of the c description to be returned
Returns:
c description with the given name, null if there is none

hasConceptWithID

public java.lang.Boolean hasConceptWithID(java.lang.String id)
Checks whether there is a c description in the current inheritance hierarchy which has the specified name.

Parameters:
id - the name to be checked
Returns:
true, if there is a description with this name, false otherwise

getAttDescsByName

public java.util.LinkedList<AttributeDesc> getAttDescsByName(java.lang.String name)
Returns a list of attribute descriptions with the given name.

Parameters:
name - the name of the attribute description's to be returned
Returns:
list of attribute description with the given name

setPath

public void setPath(java.lang.String path)
Sets the project's path to the specified path.

Parameters:
path - the project path to set

getPath

public java.lang.String getPath()
Gets the path of this project.

Returns:
the project path

getExtension

public java.lang.String getExtension()
Returns the zip file's extension. Either .zip or .prj.

Returns:
the zip file's extension

setAuthor

public void setAuthor(java.lang.String author)
Sets the author of this project.

Parameters:
author - the project author to set

getAuthor

public java.lang.String getAuthor()
Gets the author of this project.

Returns:
the project author's name

getSpecialValueDesc

public SpecialDesc getSpecialValueDesc()
Returns:
the specialValueDesc

isSpecialAttribute

public boolean isSpecialAttribute(java.lang.String obj)
Parameters:
obj - the string which is checked
Returns:
true if obj is a special value

getExplanationManager

public ExplanationManager getExplanationManager()
Returns:
the explanationManager

addSpecialValue

public void addSpecialValue(java.lang.String value)
Parameters:
value - the special value to be added

getInstance

public Instance getInstance(java.lang.String name)
Description copied from class: Concept
Returns the instance of this with name name and null if there is none.

Overrides:
getInstance in class Concept
Parameters:
name - the name of the instance to be returned
Returns:
the instance with name name, null if there is none

getInhFct

public TaxonomyFct getInhFct()
Returns the inheritance function of this c. The inheritance function describes relations of concepts known for this model. These are then used to compare object oriented cases for different concepts.

Returns:
inheritance function of this project.

setInhFct

public void setInhFct(SpecialFct f)
Changes the active special value function. Assumes that f is already a function defined for the special value description. To add another special function call SpecialDesc.addSpecialFct(String, boolean) on getSpecialValueDesc()

Parameters:
f - the new special value function

addInhFct

public TaxonomyFct addInhFct(java.lang.String name)
Creates a new InheritanceFct for myCBR's model.

Parameters:
name - the name of the new inheritance function
Returns:
the new inheritance function with name name

getSpecialFct

public SymbolFct getSpecialFct()
Returns the special function of this project. The special function computes similarities of special attributes to any sort of attribute

Returns:
the special function of this project

setSpecialValueFct

public void setSpecialValueFct(SpecialFct f)
Changes the active special function. Assumes that f is already a function defined for the special description. To add another special function call SpecialDesc.addSpecialFct(String, boolean) on getSpecialValueDesc()

Parameters:
f - the new special value function

calculateSpecialSimilarity

public Similarity calculateSpecialSimilarity(Attribute att1,
                                             Attribute att2)
Calculates the similarity of the given attributes by calling the calculateSimilarity method of the appropriate similarity function. Should be used to calculate similarity of special values.

Parameters:
att1 - the query's special value
att2 - the case's special value
Returns:
Similarity of the given attributes
Throws:
java.lang.Exception

calculateMultipleAttributeSimilarity

public Similarity calculateMultipleAttributeSimilarity(java.lang.Object simFct,
                                                       MultipleAttribute<?> att1,
                                                       MultipleAttribute<?> att2)
Calculates the similarity of the given MultipleAttribute objects based on the given similarity function.

Parameters:
simFct - the similarity function to compare simple attributes
att1 - the query's multiple value
att2 - the case's multiple value
Returns:
the similarity of att1 to att2

getSpecialAttribute

public Attribute getSpecialAttribute(java.lang.String obj)
Returns the SpecialAttribute object corresponding to the given string.

Parameters:
obj - the value for the special value attribute to be returned
Returns:
the attribute with value obj or null, if there is none
See Also:
SpecialDesc.getAttribute(String)

cleanInstances

public void cleanInstances(Concept c,
                           AttributeDesc desc)
Cleans all instances known for concept c. Since each case is an instance, the cases are clean, too.

Parameters:
c - the concept whose instances should be cleaned
desc - the cases are cleaned wrt the attribute description

removeSubConcept

public Concept removeSubConcept(java.lang.String name)
Description copied from class: Concept
Removes the sub concept with name name. Does nothing if there is no such sub concept and returns null. Adapts instances and cases.

Overrides:
removeSubConcept in class Concept
Parameters:
name - the name of the sub concept to be removed
Returns:
the Concept which has been deleted.

getSuperConcept

public Concept getSuperConcept()
Overrides:
getSuperConcept in class Concept

setSuperConcept

public void setSuperConcept(Concept c,
                            boolean isNEW)
Description copied from class: Concept
Moves this concept in the inheritance hierarchy. After this operation, the this concept will be a sub concept of c. Does nothing if c is null or c is already the super concept of this.

Overrides:
setSuperConcept in class Concept
Parameters:
c - the new super concept of this

getAttributeDescs

public java.util.HashMap<java.lang.String,AttributeDesc> getAttributeDescs()
Description copied from class: Concept
Gets the attribute descriptions of this c Be aware that the inherited attribute descriptions are not returned by this method. For all attribute descriptions belonging to this description (including inherited ones) call Concept.getAllAttributeDescs()

Overrides:
getAttributeDescs in class Concept
Returns:
the attribute descriptions that directly belong to this description

getAllAttributeDescs

public java.util.HashMap<java.lang.String,AttributeDesc> getAllAttributeDescs()
Description copied from class: Concept
Gets the attribute descriptions of this c including inherited attributes. Inherited attributes can be overridden if there is an attribute with the same name in this c and in one of the super concepts.

Overrides:
getAllAttributeDescs in class Concept
Returns:
all attribute descriptions that belong to this description

addAttributeDesc

public void addAttributeDesc(AttributeDesc desc)
                      throws java.lang.Exception
Description copied from class: Concept
Adds given description as attribute description to current c description. Do not add one attribute description to several c descriptions, but create a new one for each.

Overrides:
addAttributeDesc in class Concept
Parameters:
desc - the attribute description to be added to this description
Throws:
java.lang.Exception

removeAttributeDesc

public boolean removeAttributeDesc(java.lang.String name)
Description copied from class: Concept
Removes the attribute given by name from the attributes of this c. Does nothing if there is no attribute with this name

Overrides:
removeAttributeDesc in class Concept
Returns:
the attribute description deleted, null if none has been deleted

canOverride

public boolean canOverride(Concept c)
Overrides:
canOverride in class Concept

getProject

public Project getProject()
Description copied from class: Concept
Returns the current project.

Overrides:
getProject in class Concept
Returns:
the project

addPartOfRelation

public void addPartOfRelation(ConceptDesc desc)
Description copied from class: Concept
Adds desc as a part of relation of this concept. This means that desc is a concept description which concept equals this.

Overrides:
addPartOfRelation in class Concept
Parameters:
desc - the description which has a part-of relation to this

getPartOfRelations

public java.util.Vector<ConceptDesc> getPartOfRelations()
Description copied from class: Concept
Returns all part-of relation known for this concept.

Overrides:
getPartOfRelations in class Concept
Returns:
all part-of relation known for this concept.

deletePartOfRelation

public void deletePartOfRelation(ConceptDesc desc)
Description copied from class: Concept
Removes the given description as part-of relation. This function should either be called if the concept of desc changes or if desc is deleted.

Overrides:
deletePartOfRelation in class Concept
Parameters:
desc - the part-of relation to be removed

delete

public void delete()
Description copied from class: Concept
Deletes the concept with the given ID from this model

Overrides:
delete in class Concept

getLocalSimilarity

public Similarity getLocalSimilarity(Attribute a,
                                     Attribute b,
                                     AttributeDesc desc)
                              throws java.lang.Exception
For displaying local similarities. Should not be called for further calculations

Parameters:
a - the query attribute
b - the case attribute
desc - the attribute description underlying the given attributes
Returns:
the similarity of the given attributes
Throws:
java.lang.Exception - if something goes wrong during similarity computations

createDefaultCB

public DefaultCaseBase createDefaultCB(java.lang.String cbName,
                                       int currentCBCount)
                                throws java.lang.Exception
Used to speed up the import of case bases if the number of cases is known.

Parameters:
cbName - the name of the default case base to be created
currentCBCount - the number of expected cases
Throws:
java.lang.Exception - if there is another case base with that name

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
Specified by:
update in interface java.util.Observer
Overrides:
update in class Concept

removeCase

public void removeCase(java.lang.String name)
Removes the case with the given name from each case base.

Parameters:
name - the cases' name

getAllInstances

public java.util.Collection<Instance> getAllInstances()
Returns all instances that are known for this project.

Overrides:
getAllInstances in class Concept
Returns:
a collection of all instances known for this project.