Class CustomFormManager

java.lang.Object
it.uniroma2.art.semanticturkey.customform.CustomFormManager

@Component public class CustomFormManager extends Object
  • Constructor Details

    • CustomFormManager

      public CustomFormManager()
  • Method Details

    • init

      @PostConstruct public void init()
    • getInstance

      public static CustomFormManager getInstance()
      Return an instance of CustomFormManager. This is a workaround to use this Component as class with static methods in ProjectManager (ProjectManager is not a Component so CustomFormManager cannot be Autowired in it)
      Returns:
    • registerCustomFormModelOfProject

      public void registerCustomFormModelOfProject(Project project)
      Initializes and registers the CustomForm structure for the given project (projectName SYSTEM to initialize at system level)
      Parameters:
      project -
    • unregisterCustomFormModelOfProject

      public void unregisterCustomFormModelOfProject(Project project)
      Deregisters the CustomForm structure for the given project
      Parameters:
      project -
    • getBrokenCustomForms

      public Collection<BrokenCFStructure> getBrokenCustomForms(Project project)
      Returns all the broken CF structures, both at system and project level.
      Parameters:
      project -
      Returns:
    • getProjectFormMappings

      public Collection<FormsMapping> getProjectFormMappings(Project project)
      Returns the FormsMapping of the given project.
      Parameters:
      project -
      Returns:
    • getSystemFormMappings

      public Collection<FormsMapping> getSystemFormMappings()
      Returns the FormsMapping at system level
      Returns:
    • getReplace

      public boolean getReplace(Project project, org.eclipse.rdf4j.model.IRI resource, boolean fallback)
      Returns the replace attribute of the FormsMapping of the given resource in the given project. If no FormsMapping is defined for the resource, and the fallback parameter is true, looks for FormsMapping at system level. If no FormsMapping is defined at all for the resource return false.
      Parameters:
      resource -
      project -
      fallback -
      Returns:
    • getFormCollections

      public Collection<FormCollection> getFormCollections(Project project)
      Returns all the FormCollections at system and project level
      Returns:
    • getFormCollection

      public FormCollection getFormCollection(Project project, org.eclipse.rdf4j.model.IRI resource)
      Given a resource (property or class) returns the FormCollection linked to that resource. null if no FormCollection is linked to the resource.
      Parameters:
      resource -
      Returns:
    • getFormCollection

      public FormCollection getFormCollection(Project project, String formCollId)
      Returns the FormCollection with the given ID. It looks first at project level, then at system level. null if there is no FC with that id.
      Parameters:
      formCollId -
      Returns:
    • getSystemFormCollections

      public Collection<FormCollection> getSystemFormCollections()
      Returns all the FormCollections at system level
      Returns:
    • getSystemFormCollection

      public FormCollection getSystemFormCollection(org.eclipse.rdf4j.model.IRI resource)
      Given a resource (property or class) returns the FormCollection linked to that resource at system level. null if no FormCollection is linked to the resource.
      Parameters:
      resource -
      Returns:
    • getSystemFormCollection

      public FormCollection getSystemFormCollection(String formCollId)
      Returns the FormCollection with the given ID at system level. null if there is no FC with that id.
      Parameters:
      formCollId -
      Returns:
    • getProjectFormCollections

      public Collection<FormCollection> getProjectFormCollections(Project project)
      Returns all the FormCollections in the given project
      Returns:
    • getProjectFormCollection

      public FormCollection getProjectFormCollection(Project project, org.eclipse.rdf4j.model.IRI resource)
      Given a resource (property or class) returns the FormCollection linked to that resource in the given project. null if no FormCollection is linked to the resource.
      Parameters:
      resource -
      Returns:
    • getProjectFormCollection

      public FormCollection getProjectFormCollection(Project project, String formCollId)
      Returns the FormCollection with the given ID in the given project. null if there is no FC with that id.
      Parameters:
      formCollId -
      Returns:
    • getCustomForms

      public Collection<CustomForm> getCustomForms(Project project)
      Returns all the CustomForms at system and project level
      Returns:
    • getCustomForm

      public CustomForm getCustomForm(Project project, String customFormId)
      Returns the CustomForm with the given ID. It looks first at project level, then at system level.
      Parameters:
      project -
      customFormId -
      Returns:
    • getCustomForms

      public Collection<CustomForm> getCustomForms(Project project, org.eclipse.rdf4j.model.IRI resource)
      Returns the CustomForm for the given resource. It looks at project level and system level If the resource has not a FormCollection linked, then returns an empty collection.
      Parameters:
      project -
      resource -
      Returns:
    • getSystemCustomForms

      public Collection<CustomForm> getSystemCustomForms()
      Returns all the CustomForms at system level
      Returns:
    • getSystemCustomForm

      public CustomForm getSystemCustomForm(String customFormId)
      Returns the CustomForm with the given ID at system level
      Parameters:
      customFormId -
      Returns:
    • getSystemCustomForms

      public Collection<CustomForm> getSystemCustomForms(org.eclipse.rdf4j.model.IRI resource)
      Returns all the CustomForm for the given resource at system level. If the resource has not a FormCollection linked, then returns an empty collection
      Parameters:
      resource -
      Returns:
    • getProjectCustomForms

      public Collection<CustomForm> getProjectCustomForms(Project project)
      Returns all the CustomForms for the given project
      Returns:
    • getProjectCustomForms

      public Collection<CustomForm> getProjectCustomForms(Project project, org.eclipse.rdf4j.model.IRI resource)
      Returns all the CustomForm for the given resource of the given project. If the resource has not a FormCollection linked, then returns an empty collection.
      Parameters:
      project -
      resource -
      Returns:
    • getProjectCustomForm

      public CustomForm getProjectCustomForm(Project project, String customFormId)
      Returns the CustomForm with the given ID of the given project
      Parameters:
      project -
      customFormId -
      Returns:
    • getAllCustomFormGraphs

      public Collection<CustomFormGraph> getAllCustomFormGraphs(Project project, org.eclipse.rdf4j.model.IRI resource)
      Returns all the CustomFormGraph for the given resource (at project and stystem level)
      Parameters:
      resource -
      Returns:
    • existsCustomFormGraphForResource

      public boolean existsCustomFormGraphForResource(Project project, org.eclipse.rdf4j.model.IRI resource)
      Tells whether a resource has or not a CustomForm of type graph
      Parameters:
      resource -
      Returns:
    • getCustomFormGraphSeed

      public CustomFormGraph getCustomFormGraphSeed(Project project, it.uniroma2.art.coda.core.CODACore codaCore, org.eclipse.rdf4j.repository.RepositoryConnection repoConnection, org.eclipse.rdf4j.model.Resource resource, Collection<org.eclipse.rdf4j.model.IRI> predicateOrClasses, boolean includeInferred)
      Returns the CustomFormGraph that probably generated the reified resource. If for the given resource there is no CustomForm available returns null, if there's just one CustomForm then return it, otherwise if there are multiple CustomForm returns the one which its PEARL fits better the given reified resource description.
      Parameters:
      project -
      codaCore -
      repoConnection -
      resource -
      predicateOrClasses -
      includeInferred -
      Returns:
      Throws:
      it.uniroma2.art.coda.exception.RDFModelNotSetException
    • addFormsMapping

      public FormsMapping addFormsMapping(Project project, org.eclipse.rdf4j.model.IRI resource, FormCollection formColl, boolean replace) throws CustomFormException
      Adds a FormsMapping (mapping between resource and FormCollection) to the configuration of the given project. If a FormCollection is already assigned to the given resource, throws a CustomFormException.
      Parameters:
      resource -
      formColl -
      replace -
      project -
      Returns:
      Throws:
      CustomFormException
    • createFormCollection

      public FormCollection createFormCollection(Project project, String id) throws DuplicateIdException
      Creates and adds a FormCollection in the given project. If in the project, a FormCollection with the same ID exists, a DuplicateIdException is thrown
      Parameters:
      id -
      Returns:
      Throws:
      DuplicateIdException
    • createCustomFormGraph

      public CustomFormGraph createCustomFormGraph(Project project, String id, String name, String description, String ref) throws DuplicateIdException
      Creates and adds a CustomFormGraph in the given project. If in the project, a CustomForm with the same ID exists, a DuplicateIdException is thrown
      Parameters:
      id -
      name -
      description -
      ref -
      Returns:
      Throws:
      DuplicateIdException
    • createCustomFormNode

      public CustomFormNode createCustomFormNode(Project project, String id, String name, String description, String ref) throws DuplicateIdException
      Creates and adds a CustomFormNode in the given project. If in the project, a CustomForm with the same ID exists, a DuplicateIdException is thrown
      Parameters:
      id -
      name -
      description -
      ref -
      Returns:
      Throws:
      DuplicateIdException
    • setReplace

      public void setReplace(Project project, org.eclipse.rdf4j.model.IRI resource, boolean replace) throws CustomFormException
      Throws:
      CustomFormException
    • removeFormsMapping

      public void removeFormsMapping(Project project, org.eclipse.rdf4j.model.IRI resource)
      Removes a FormsMapping (mapping between resource and FormCollection) from the configuration of the given project.
      Parameters:
      resource -
      project -
    • updateFormCollection

      public void updateFormCollection(Project project, FormCollection formColl, Collection<CustomForm> customForms, Collection<org.eclipse.rdf4j.model.IRI> suggestions)
    • deleteFormCollection

      public void deleteFormCollection(Project project, FormCollection formColl)
      Removes a FormCollection from the configuration of the given project and its file from file-system
      Parameters:
      project -
      formColl -
    • updateCustomFormNode

      public void updateCustomFormNode(Project project, CustomFormNode customForm, String name, String description, String ref)
    • updateCustomFormGraph

      public void updateCustomFormGraph(Project project, CustomFormGraph customForm, String name, String description, String ref)
    • deleteCustomForm

      public void deleteCustomForm(Project project, CustomForm customForm, boolean deleteEmptyColl)
      Removes a CustomForm from the form collection of a project
      Parameters:
      customForm -
      deleteEmptyColl - if true deletes FormCollection that are left empty after the deletion
    • getCustomFormsFolder

      public static File getCustomFormsFolder(Project project)
      Returns the customForms folder for the given project, or at system level if projectName is null
      Returns:
    • getFormCollectionsFolder

      public static File getFormCollectionsFolder(Project project)
      Returns the formCollections folder for the given project, or at system level if projectName is null
      Returns:
    • getFormsFolder

      public static File getFormsFolder(Project project)
      Returns the forms folder for the given project, or at system level if projectName is null
      Returns: