public class Project
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
static java.util.regex.Pattern |
RESOURCE_NAME_PATTERN
A basic name validation pattern that needs a character, underscore, or digit to start with, and then will also
accept spaces and parens afterwards.
|
Constructor and Description |
---|
Project(long id,
java.lang.String name,
java.lang.String title,
java.lang.String description,
java.util.Date lastModified,
java.lang.String lastModifiedBy,
long editCount,
java.util.UUID uuid) |
Project(Project copy) |
Modifier and Type | Method and Description |
---|---|
void |
applyDiff(Project project)
Applies this project as a diff to another project.
|
void |
applyDiff(Project project,
boolean dirty)
Applies this project as a diff to another project.
|
boolean |
basePropsEqual(Project p)
Are the base properties (name, title, description) equal?
|
java.util.List<ProjectResource> |
browseFolder(java.lang.String moduleId,
java.util.Collection<java.lang.String> resourceTypes,
java.util.UUID parent)
Returns resources whose parent matches the parent argument.
|
java.util.List<ProjectResource> |
browseFolder(java.lang.String moduleId,
java.lang.String resourceType,
boolean includeFolders,
java.util.UUID parent)
Equivalent to browseFolder with a set that includes the given resource type, and maybe the folder resource type
depending on the flag.
|
static boolean |
checkProjectVersion(java.io.File projFile) |
static boolean |
checkVersion(java.io.InputStream xml) |
static boolean |
checkVersion(java.io.Reader xml) |
void |
clearAllFlags() |
<T> T |
decodeOrCreate(java.lang.String moduleId,
java.lang.String resourceType,
XMLDeserializer deserializer,
java.lang.Class<T> clazz)
Convenience function that looks for a single project resource with the given module id and resource type.
|
<T> T |
decodeOrCreate(java.lang.String moduleId,
java.lang.String resourceType,
XMLDeserializer deserializer,
java.lang.Class<T> clazz,
org.apache.log4j.Logger log) |
boolean |
deletedResourcesAffectScope(int scope)
Returns true if any of the deleted resources are part of the given scope
|
void |
deleteResource(long resourceId)
Removes the given resource from the project
|
void |
deleteResource(long resourceId,
boolean markDeleted)
Removes the given resource, optionally marking it as removed
|
ProjectResource |
findFolder(java.util.UUID uuid)
Looks up a folder with the given UUID.
|
java.lang.Long |
findResource(java.lang.String moduleId,
java.util.UUID root,
java.lang.String folderPath)
Searches for a given resource along the folder path specified.
|
java.lang.Long |
findResource(java.lang.String moduleId,
java.util.UUID root,
java.lang.String folderPath,
java.lang.String resourceType)
Searches for a given resource along the folder path specified.
|
static Project |
fromXML(java.io.InputStream xml) |
static Project |
fromXML(java.io.InputStream xml,
boolean forImport) |
static Project |
fromXML(java.io.Reader xml) |
static Project |
fromXML(java.io.Reader xml,
boolean forImport) |
java.awt.datatransfer.Transferable |
getClipboardCopy()
Returns a StringSelection transferable that holds to toXML() version of this project object.
|
java.util.Set<java.lang.Long> |
getDeletedResources() |
java.lang.Integer |
getDeletedResourceScope(long id) |
java.lang.String |
getDescription() |
Project |
getDiff()
Returns this a new project containing only this project's dirty resources
|
Project |
getDiff(boolean preserveDirty)
Returns this a new project containing only this project's dirty resources
|
java.util.List<ProjectResource> |
getDirtyResources()
Returns all dirty resources, but does not unlock them.
|
java.lang.String |
getDisplayTitle()
Returns the title of the project, unless it isn't specified, in which case the name is returned.
|
long |
getEditCount() |
Project |
getEmptyCopy()
Returns a copy of the project without any project resources
|
java.lang.String |
getFolderPath(long resourceId)
Derives the given resource's folder path, like "MyFolder/SubFolder/MyResource".
|
java.lang.String |
getFolderPath(long resourceId,
boolean includeResourceName)
Derives the given resource's folder path, like "MyFolder/SubFolder/MyResource".
|
java.util.List<ProjectResource> |
getFolders(java.lang.String moduleId,
java.util.UUID parent)
Returns resources of type folder for the given module id under the prescribed parent.
|
long |
getId() |
java.util.Date |
getLastModified() |
java.lang.String |
getLastModifiedBy() |
java.lang.String |
getName() |
int |
getProjectSize() |
ProjectResource |
getResource(long id)
Looks up a project resource by id.
|
protected ProjectResource |
getResource(long id,
boolean unlock) |
int |
getResourceCount() |
ProjectResource |
getResourceOfType(java.lang.String moduleId,
java.lang.String type)
Convenience function that returns the first resource for a given module/type, or null if there is none.
|
java.util.List<ProjectResource> |
getResources()
Returns all resources - dirty and clean- but does not unlock them.
|
java.util.List<ProjectResource> |
getResourcesOfType(java.lang.String moduleId,
java.lang.String type)
Returns a list of all the project resources in this project with the given module and type.
|
java.lang.String |
getRuntimeLockId()
Returns the id of the lock used to protect this project.
|
java.lang.String |
getSource() |
java.lang.String |
getTitle() |
java.util.UUID |
getUuid() |
static boolean |
hasVersionInfo(java.io.File projFile) |
static boolean |
hasVersionInfo(java.io.InputStream xml) |
static boolean |
hasVersionInfo(java.io.Reader xml) |
boolean |
isEmpty()
True if this project contains no resources or deleted resource markers
|
boolean |
isEnabled() |
boolean |
isResource(long id)
Some times we just need to know if a resource still exists....
|
boolean |
isResourceDeleted(long resourceId) |
boolean |
isResourceDirty(java.lang.Long id) |
boolean |
isResourceDirty(ProjectResource resource) |
boolean |
isRuntimeLocked()
Returns whether or not this project has been locked using a Runtime Lock license.
|
protected ProjectResource |
lock(ProjectResource resource) |
void |
markDeleted(long resourceId,
int scope)
Function for marking a resource deleted when it doesn't exist in the project
|
void |
putResource(ProjectResource resource)
Puts a resource in the project, and marks it dirty
|
void |
putResource(ProjectResource resource,
boolean dirty)
Puts the resource in the project specifying whether or not it should by dirty
|
void |
setDescription(java.lang.String description) |
void |
setEditCount(long editCount) |
void |
setEnabled(boolean enabled) |
void |
setId(long id) |
void |
setLastModified(java.util.Date lastModified) |
void |
setLastModifiedBy(java.lang.String lastModifiedBy) |
void |
setName(java.lang.String name) |
void |
setRuntimeLock(RuntimeLock lock)
Sets the runtime lock to use for this project.
|
void |
setSource(java.lang.String source) |
void |
setTitle(java.lang.String title) |
void |
setUuid(java.util.UUID uuid) |
void |
toXML(java.io.OutputStream outstream)
Outputs the project as XML to the output stream.
|
void |
toXML(java.io.OutputStream outstream,
boolean dirtyOnly,
boolean exportOrCopy) |
void |
toXML(java.io.PrintWriter out,
boolean dirtyOnly,
boolean exportOrCopy) |
void |
toXMLCopyOrExport(java.io.OutputStream out)
Outputs the project as XML to the output stream.
|
protected ProjectResource |
unlock(ProjectResource resource)
Returns an unlocked (unencrypted) version of the resource, if the Project is using Runtime Locking.
|
public static final java.util.regex.Pattern RESOURCE_NAME_PATTERN
public Project(long id, java.lang.String name, java.lang.String title, java.lang.String description, java.util.Date lastModified, java.lang.String lastModifiedBy, long editCount, java.util.UUID uuid)
public Project(Project copy)
public boolean basePropsEqual(Project p)
public int getResourceCount()
public void setRuntimeLock(RuntimeLock lock)
lock
- public boolean isRuntimeLocked()
public java.lang.String getRuntimeLockId()
public boolean isEmpty()
public Project getEmptyCopy()
public Project getDiff()
public Project getDiff(boolean preserveDirty)
preserveDirty
- Whether or not to mark the resources in the diff copy as dirty.public void clearAllFlags()
public int getProjectSize()
public void putResource(ProjectResource resource)
resource
- public void putResource(@Nonnull ProjectResource resource, boolean dirty)
resource
- dirty
- public void deleteResource(long resourceId)
resourceId
- public void deleteResource(long resourceId, boolean markDeleted)
resourceId
- protected ProjectResource unlock(ProjectResource resource)
resource
- protected ProjectResource lock(ProjectResource resource)
public void markDeleted(long resourceId, int scope)
public java.util.List<ProjectResource> getResources()
public java.util.List<ProjectResource> getResourcesOfType(java.lang.String moduleId, java.lang.String type)
type
- public ProjectResource getResourceOfType(java.lang.String moduleId, java.lang.String type)
public java.util.List<ProjectResource> getFolders(java.lang.String moduleId, java.util.UUID parent)
ProjectResource.FOLDER_RESOURCE_TYPE
public java.util.List<ProjectResource> browseFolder(java.lang.String moduleId, java.lang.String resourceType, boolean includeFolders, java.util.UUID parent)
public java.util.List<ProjectResource> browseFolder(java.lang.String moduleId, java.util.Collection<java.lang.String> resourceTypes, java.util.UUID parent)
moduleId
- The module id of resources to return. Cannot be null.resourceTypes
- The resource type of resources to return. If null or empty, resources of all types will be returned.parent
- The parent folder's UUID to match. Can be null.public ProjectResource findFolder(java.util.UUID uuid)
public java.lang.Long findResource(java.lang.String moduleId, java.util.UUID root, java.lang.String folderPath)
public java.lang.Long findResource(java.lang.String moduleId, java.util.UUID root, java.lang.String folderPath, java.lang.String resourceType)
moduleId
- The string ID of the module that the resources belong toroot
- The folder root UUID.folderPath
- The path to the resource.resourceType
- the string type of the resourcepublic java.lang.String getFolderPath(long resourceId)
resourceId
- The ID of the resource to calculate the folder path forpublic java.lang.String getFolderPath(long resourceId, boolean includeResourceName)
resourceId
- The ID of the resource to calculate the folder path forincludeResourceName
- Whether or not to include the resource itself in the path, or just use the path of its parent.public <T> T decodeOrCreate(java.lang.String moduleId, java.lang.String resourceType, XMLDeserializer deserializer, java.lang.Class<T> clazz) throws java.lang.Exception
T
- moduleId
- The module id for the project resource to look for.resourceType
- The resource type for the project resource to look for.deserializer
- An XML Deserializer to use to deserialize the project resource, if it is found.clazz
- The desired type. Any serialized object of the found resource must be one of these.java.lang.Exception
public <T> T decodeOrCreate(java.lang.String moduleId, java.lang.String resourceType, XMLDeserializer deserializer, java.lang.Class<T> clazz, org.apache.log4j.Logger log) throws java.lang.Exception
java.lang.Exception
public ProjectResource getResource(long id)
id
- protected ProjectResource getResource(long id, boolean unlock)
public boolean isResource(long id)
id
- public java.util.List<ProjectResource> getDirtyResources()
public boolean isResourceDirty(ProjectResource resource)
public boolean isResourceDirty(java.lang.Long id)
public boolean isResourceDeleted(long resourceId)
public void applyDiff(Project project)
project
- public void applyDiff(Project project, boolean dirty)
project
- dirty
- Specifies whether the resources in this diff should be marked as dirty and marked deleted in the
target projectpublic java.util.Set<java.lang.Long> getDeletedResources()
public boolean deletedResourcesAffectScope(int scope)
public java.lang.Integer getDeletedResourceScope(long id)
public long getId()
public void setId(long id)
public java.lang.String getName()
public void setName(java.lang.String name)
public java.lang.String getSource()
public void setSource(java.lang.String source)
public boolean isEnabled()
public void setEnabled(boolean enabled)
public java.util.UUID getUuid()
public void setUuid(java.util.UUID uuid)
public java.lang.String getTitle()
public java.lang.String getDisplayTitle()
public void setTitle(java.lang.String title)
public java.lang.String getDescription()
public void setDescription(java.lang.String description)
public java.awt.datatransfer.Transferable getClipboardCopy()
public void toXML(java.io.OutputStream outstream)
outstream
- public void toXMLCopyOrExport(java.io.OutputStream out)
out
- public void toXML(java.io.OutputStream outstream, boolean dirtyOnly, boolean exportOrCopy)
public void toXML(java.io.PrintWriter out, boolean dirtyOnly, boolean exportOrCopy)
public static Project fromXML(java.io.InputStream xml) throws org.xml.sax.SAXException, java.io.IOException
org.xml.sax.SAXException
java.io.IOException
public static Project fromXML(java.io.Reader xml) throws org.xml.sax.SAXException, java.io.IOException
org.xml.sax.SAXException
java.io.IOException
public static Project fromXML(java.io.InputStream xml, boolean forImport) throws org.xml.sax.SAXException, java.io.IOException
org.xml.sax.SAXException
java.io.IOException
public static Project fromXML(java.io.Reader xml, boolean forImport) throws org.xml.sax.SAXException, java.io.IOException
org.xml.sax.SAXException
java.io.IOException
public static boolean checkProjectVersion(java.io.File projFile)
public static boolean checkVersion(java.io.InputStream xml) throws org.xml.sax.SAXException, java.io.IOException
org.xml.sax.SAXException
java.io.IOException
public static boolean checkVersion(java.io.Reader xml) throws org.xml.sax.SAXException, java.io.IOException
org.xml.sax.SAXException
java.io.IOException
public static boolean hasVersionInfo(java.io.File projFile)
public static boolean hasVersionInfo(java.io.InputStream xml) throws org.xml.sax.SAXException, java.io.IOException
org.xml.sax.SAXException
java.io.IOException
public static boolean hasVersionInfo(java.io.Reader xml) throws org.xml.sax.SAXException, java.io.IOException
org.xml.sax.SAXException
java.io.IOException
public java.util.Date getLastModified()
public void setLastModified(java.util.Date lastModified)
public java.lang.String getLastModifiedBy()
public void setLastModifiedBy(java.lang.String lastModifiedBy)
public long getEditCount()
public void setEditCount(long editCount)