Class ResourceMapModifier
java.lang.Object
edu.ucsb.nceas.metacat.dataone.resourcemap.ResourceMapModifier
This class will create a new resource map by modifying a given resourceMap input stream.
Note: this class can only be used on the mn.publish method since it will replace the all old pid existing places by the new id. It is only safe for the the mn.publish method.
- Author:
- tao
-
Field Summary
-
Constructor Summary
ConstructorDescriptionResourceMapModifier
(org.dataone.service.types.v1.Identifier oldResourceMapId, InputStream originalResourceMap, org.dataone.service.types.v1.Identifier newResourceMapId) Constructor -
Method Summary
Modifier and TypeMethodDescriptionstatic com.hp.hpl.jena.rdf.model.Resource
generateAgentResource
(org.dataone.service.types.v1.Subject subject, com.hp.hpl.jena.rdf.model.Model model) Generate an agent resource.static com.hp.hpl.jena.rdf.model.Resource
generateNewComponent
(com.hp.hpl.jena.rdf.model.Model model, String id) Create a Resource object for the given id.static com.hp.hpl.jena.rdf.model.Resource
generateNewOREResource
(com.hp.hpl.jena.rdf.model.Model model, org.dataone.service.types.v1.Subject subject, org.dataone.service.types.v1.Identifier newId) This method generates a Resource object for the new ore id in the given modelstatic com.hp.hpl.jena.rdf.model.Resource
getResource
(com.hp.hpl.jena.rdf.model.Model model, String id) Get the Resource object which has the given identifierList<org.dataone.service.types.v1.Identifier>
getSubjectsOfDocumentedBy
(org.dataone.service.types.v1.Identifier metadataId) Get all subjects of the triple - * is documentedBy metadataId on the resource mapstatic List<org.dataone.service.types.v1.Identifier>
getSubjectsOfDocumentedBy
(org.dataone.service.types.v1.Identifier metadataId, com.hp.hpl.jena.rdf.model.Model dataModel) Get all subjects of the triple - * is documentedBy metadataId in the given modelvoid
replaceObsoletedId
(org.dataone.service.types.v1.Identifier obsoletedId, org.dataone.service.types.v1.Identifier newId, OutputStream newResourceMap, org.dataone.service.types.v1.Subject subject) Create new resource map by replacing obsoleted ids by new ids.
-
Field Details
-
DEFAULT_CN_URI
- See Also:
-
SLASH
- See Also:
-
RESOLVE
- See Also:
-
TERM_NAMESPACE
- See Also:
-
CITO_NAMESPACE
- See Also:
-
ORE_TER_NAMESPACE
- See Also:
-
RDF_NAMESPACE
- See Also:
-
AGGREGATION
- See Also:
-
AGENT_URI
- See Also:
-
baseURI
-
-
Constructor Details
-
ResourceMapModifier
public ResourceMapModifier(org.dataone.service.types.v1.Identifier oldResourceMapId, InputStream originalResourceMap, org.dataone.service.types.v1.Identifier newResourceMapId) Constructor- Parameters:
oldResourceMapId
- the identifier of the old resource map which will be modifiedoriginalResourceMap
- the content of original resource mapnewResourceMapId
- the identifier of the new resource map which will be generated
-
-
Method Details
-
replaceObsoletedId
public void replaceObsoletedId(org.dataone.service.types.v1.Identifier obsoletedId, org.dataone.service.types.v1.Identifier newId, OutputStream newResourceMap, org.dataone.service.types.v1.Subject subject) throws UnsupportedEncodingException Create new resource map by replacing obsoleted ids by new ids. Note: this method can only be used on the mn.publish method since it will replace the all old pid existing places by the new id. It is only safe for the the mn.publish method.- Parameters:
obsoletedId
- the pid will be replacednewId
- the pid will be used to replace the old pidnewResourceMap
- the place where the created new resource map will be writtensubject
- the subject who generates the resource map- Throws:
UnsupportedEncodingException
-
generateNewOREResource
public static com.hp.hpl.jena.rdf.model.Resource generateNewOREResource(com.hp.hpl.jena.rdf.model.Model model, org.dataone.service.types.v1.Subject subject, org.dataone.service.types.v1.Identifier newId) throws UnsupportedEncodingException This method generates a Resource object for the new ore id in the given model- Parameters:
model
- the model where the new generated Resource object will be attachedsubject
- name of the creator of this resource map- Returns:
- the generated new ORE Resource object
- Throws:
UnsupportedEncodingException
-
generateAgentResource
public static com.hp.hpl.jena.rdf.model.Resource generateAgentResource(org.dataone.service.types.v1.Subject subject, com.hp.hpl.jena.rdf.model.Model model) Generate an agent resource. If there is an existing agent with the same name and the type, the existing agent will be returned.- Parameters:
subject
- the name of the agent resource- Returns:
- the agent resource
-
generateNewComponent
public static com.hp.hpl.jena.rdf.model.Resource generateNewComponent(com.hp.hpl.jena.rdf.model.Model model, String id) throws UnsupportedEncodingException Create a Resource object for the given id.- Parameters:
model
- the model where the new Resource object will be attachedid
- the identifier of the new Resource object will have- Returns:
- the uri of the new generated Resource object
- Throws:
UnsupportedEncodingException
-
getResource
public static com.hp.hpl.jena.rdf.model.Resource getResource(com.hp.hpl.jena.rdf.model.Model model, String id) Get the Resource object which has the given identifier- Parameters:
model
- the model where the query will be appliedid
- the identifier of the Resource object has- Returns:
- the Resource object with the given identifier. It can return null if not found.
-
getSubjectsOfDocumentedBy
public List<org.dataone.service.types.v1.Identifier> getSubjectsOfDocumentedBy(org.dataone.service.types.v1.Identifier metadataId) Get all subjects of the triple - * is documentedBy metadataId on the resource map- Parameters:
metadataId
- the id of object on the triple (it always be a metadata id). If it is null, it will be anything.- Returns:
- the all the identifiers of the subjects match the query
-
getSubjectsOfDocumentedBy
public static List<org.dataone.service.types.v1.Identifier> getSubjectsOfDocumentedBy(org.dataone.service.types.v1.Identifier metadataId, com.hp.hpl.jena.rdf.model.Model dataModel) Get all subjects of the triple - * is documentedBy metadataId in the given model- Parameters:
metadataId
- the id of object on the triple (it always be a metadata id). If it is null, it will be anything.dataModel
- the model of the result map- Returns:
- the all the identifiers of the subjects match the query
-