Class Project
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.vilTypes.Project
-
- All Implemented Interfaces:
IStringValueProvider,IVilType
public class Project extends java.lang.Object implements IVilType, IStringValueProvider
Represents the physical project we are operating on. Callrelease()if the instance is not used anymore.- Author:
- Holger Eichelberger
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.ssehub.easy.instantiation.core.model.vilTypes.IStringValueProvider
IStringValueProvider.StringComparator
-
-
Field Summary
Fields Modifier and Type Field Description private ArtifactModelartifactModelprivate java.io.Filebaseprivate static java.util.Map<java.lang.String,Project>CACHEprivate IProjectDescriptordescriptorprivate booleanemptyprivate java.lang.Stringname
-
Constructor Summary
Constructors Modifier Constructor Description Project()Creates an empty project without scanning.Project(java.io.File base, ProgressObserver observer)Creates a project for a givenbasedirectory.privateProject(IProjectDescriptor descriptor, ProgressObserver observer)Creates a project based on a givendescriptor.Project(Project project, ProgressObserver observer)Creates a new project by for the base directory given inproject.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidclearProjectDescriptorCache()Clears the project descriptor cache.static Pathconvert(Project project)Converts a project to its base path.private PathcreatePathWithFallback(IProjectDescriptor.ModelKind kind)Creates a model path with default fallback.protected voidfinalize()ArtifactModelgetArtifactModel()Returns the underlying artifact model.PathgetEasyFolder()Returns the path to the EASy files.PathgetIvmlFolder()Returns the path to the IVML model files.Set<FileArtifact>getLocalProjectArtifacts()Returns the local project artifacts.ScriptgetMainVilScript()Returns the main VIL script of the project.java.lang.StringgetName()Returns the name of the project.PathgetPath()Returns the path of this project.static ProjectgetProjectFor(IProjectDescriptor descriptor)Returns a cached project or caches a new one fordescriptor.java.lang.ObjectgetSettings(ProjectSettings key)Returns the settings object for the specified key.java.lang.StringgetStringValue(IStringValueProvider.StringComparator comparator)Returns the string value of this object.PathgetVilFolder()Returns the path to the VIL model files.PathgetVtlFolder()Returns the path to the VTL model files.Pathlocalize(Project source, IFileSystemArtifact artifact)Localizes the givenpathtaken from source with respect to this project.Pathlocalize(Project source, Path path)Localizes the givenpathtaken from source with respect to this project.Set<Project>predecessors()Returns the predecessors of this project.voidrelease()Releases this instance and the related artifact model.Set<FileArtifact>selectAllFiles()Returns all files.Set<FolderArtifact>selectAllFolders()Returns all folders.Set<FileArtifact>selectByKind(java.lang.Class<?> type)Does type selection of artifacts by type or sub-type.Set<FileArtifact>selectByName(java.lang.String name)Does name selection of artifacts.Set<FileArtifact>selectByType(java.lang.Class<?> type)Does type selection of artifacts type equality.voidsetSettings(ProjectSettings key, java.lang.Object object)Sets the settings for the artifact model.Set<FileArtifact>typeReject(java.lang.Class<?> type)Does type selection of artifacts by not matching type or sub-type.
-
-
-
Field Detail
-
CACHE
private static final java.util.Map<java.lang.String,Project> CACHE
-
artifactModel
private ArtifactModel artifactModel
-
base
private java.io.File base
-
descriptor
private IProjectDescriptor descriptor
-
empty
private boolean empty
-
name
private java.lang.String name
-
-
Constructor Detail
-
Project
public Project()
Creates an empty project without scanning. Just for testing.
-
Project
public Project(java.io.File base, ProgressObserver observer) throws VilExceptionCreates a project for a givenbasedirectory.- Parameters:
base- the base directory (shall be an absolute path)observer- to notify the caller in case of long-running scans- Throws:
VilException- in case that the creation of artifacts fails
-
Project
public Project(Project project, ProgressObserver observer) throws VilException
Creates a new project by for the base directory given inproject. Please note that this constructor is intended to be called to re-instantiateprojectafterrelease()has been called onproject. Thereby, the instance created by this constructor is fully initialized with a artifact model and, dependent onproject, also an artifact scan is executed. This constructor is mainly intended to allow testing based on the VIL execution visitor and the VIL executor afterwards in sequence.- Parameters:
project- the project the data shall be taken fromobserver- to notify the caller in case of long-running scans- Throws:
VilException- in case that the creation of artifacts fails
-
Project
private Project(IProjectDescriptor descriptor, ProgressObserver observer) throws VilException
Creates a project based on a givendescriptor.- Parameters:
descriptor- the descriptor to create the project forobserver- to notify the caller in case of long-running scans- Throws:
VilException- in case that the creation of artifacts fails
-
-
Method Detail
-
getName
public java.lang.String getName()
Returns the name of the project.- Returns:
- the name of the project
-
selectAllFiles
public Set<FileArtifact> selectAllFiles()
Returns all files.- Returns:
- all files
-
selectAllFolders
public Set<FolderArtifact> selectAllFolders()
Returns all folders.- Returns:
- all folders
-
getPath
public Path getPath()
Returns the path of this project.- Returns:
- the path
-
localize
public Path localize(Project source, Path path)
Localizes the givenpathtaken from source with respect to this project.- Parameters:
source- the source projectpath- the target path- Returns:
- the localized path
-
localize
public Path localize(Project source, IFileSystemArtifact artifact) throws VilException
Localizes the givenpathtaken from source with respect to this project.- Parameters:
source- the source projectartifact- the target artifact- Returns:
- the localized path
- Throws:
VilException- in case that localization is not possible due toartifact
-
getLocalProjectArtifacts
public Set<FileArtifact> getLocalProjectArtifacts()
Returns the local project artifacts.- Returns:
- the local artifacts
-
selectByType
public Set<FileArtifact> selectByType(java.lang.Class<?> type)
Does type selection of artifacts type equality.- Parameters:
type- the target type- Returns:
- the selected artifacts (the type will be adjusted to the actual
type of
type)
-
selectByKind
public Set<FileArtifact> selectByKind(java.lang.Class<?> type)
Does type selection of artifacts by type or sub-type.- Parameters:
type- the target type- Returns:
- the selected artifacts (the type will be adjusted to the actual
type of
type)
-
typeReject
public Set<FileArtifact> typeReject(java.lang.Class<?> type)
Does type selection of artifacts by not matching type or sub-type.- Parameters:
type- the target type- Returns:
- the selected artifacts (the type will be adjusted to the actual
type of
type)
-
selectByName
public Set<FileArtifact> selectByName(java.lang.String name)
Does name selection of artifacts.- Parameters:
name- the regular name pattern for artifact selection- Returns:
- the selected artifacts
-
getProjectFor
public static Project getProjectFor(IProjectDescriptor descriptor) throws VilException
Returns a cached project or caches a new one fordescriptor. This method shall only be called on the root successor as caching will only work there!- Parameters:
descriptor- the descriptor to return the project for- Returns:
- the related project
- Throws:
VilException- in case that creating / scanning the project base fails
-
clearProjectDescriptorCache
public static void clearProjectDescriptorCache()
Clears the project descriptor cache. Handle with care and do not call this during a VIL execution!
-
predecessors
public Set<Project> predecessors() throws VilException
Returns the predecessors of this project.- Returns:
- the predecessors
- Throws:
VilException- in case that creating / scanning the project base fails
-
getStringValue
public java.lang.String getStringValue(IStringValueProvider.StringComparator comparator)
Description copied from interface:IStringValueProviderReturns the string value of this object.- Specified by:
getStringValuein interfaceIStringValueProvider- Parameters:
comparator- if the sequence of elements, e.g., in case of collections, shall be ordered according to the comparator, null if the original sequence shall be returned- Returns:
- the string value
-
getEasyFolder
public Path getEasyFolder()
Returns the path to the EASy files.- Returns:
- the path to the EASy files
-
getIvmlFolder
public Path getIvmlFolder()
Returns the path to the IVML model files.- Returns:
- the path to the IVML model files
-
getVilFolder
public Path getVilFolder()
Returns the path to the VIL model files.- Returns:
- the path to the VIL model files
-
getVtlFolder
public Path getVtlFolder()
Returns the path to the VTL model files.- Returns:
- the path to the VTL model files
-
createPathWithFallback
private Path createPathWithFallback(IProjectDescriptor.ModelKind kind)
Creates a model path with default fallback.- Parameters:
kind- the kind of the models- Returns:
- the path
-
release
public void release()
Releases this instance and the related artifact model.
-
finalize
protected void finalize() throws java.lang.Throwable- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
getArtifactModel
public ArtifactModel getArtifactModel()
Returns the underlying artifact model.- Returns:
- the underlying artifact model
-
convert
public static Path convert(Project project)
Converts a project to its base path.- Parameters:
project- the project to be converted- Returns:
- the base path of
project
-
getMainVilScript
public Script getMainVilScript()
Returns the main VIL script of the project.- Returns:
- the main VIL script
-
setSettings
public void setSettings(ProjectSettings key, java.lang.Object object)
Sets the settings for the artifact model.- Parameters:
key- ID for the settings objectobject- the settings
-
getSettings
public java.lang.Object getSettings(ProjectSettings key)
Returns the settings object for the specified key.- Parameters:
key- the key assigned to the settings object- Returns:
- the settings object
-
-