I am a developer and actually I use the powerfull tools mozilla provides for
developers.
I miss one thing, that may be important in my opinion.
an RDF clipboard. That is, a component to provide some functionallity with
RDF Datasources to copy and paste resources from one datsource to another.
I have a primer implementation in javascript, but I think would be
interesting
code it in C++, and add an interface like nsIRDFClipboard to access this
methods.
What do you think?
Thank you all
Leo.
> I have a primer implementation in javascript, but I think would be
> interesting
> code it in C++, and add an interface like nsIRDFClipboard to access this
> methods.
I'd be interested in seeing your proposal for a the "clipboard"
interface, either in IDL or as javascript code. Can you open an
enhancement bug for RDF in bugzilla on this?
ct
Gavin
> _______________________________________________
> Mozilla-rdf mailing list
> Mozil...@mozilla.org
> http://mail.mozilla.org/listinfo/mozilla-rdf
--
Gavin Doughtie
DreamWorks SKG
(818) 695-3821
RDFNode.prototype.copyToDatasource=
function (dsource2)
{
var kids = this.getChildren();
if (kids) {
while (kids.hasMoreElements()) { // recursive copy
kids.getNext().copyToDatasource(anRdfDatasource);
}
}
var orig = dsource2;
var dsource1=this.datasource;
dsource2=dsource2.datasource;
var source = this.source;
var props=dsource1.ArcLabelsOut(source);
while(props.hasMoreElements()){
var prop=props.getNext();
prop=prop.QueryInterface(Components.interfaces.nsIRDFResource);
var target=dsource1.GetTarget(source,prop,true);
if (target!=null) dsource2.Assert(source,prop,target,true);
}
return orig.getNode(this.getValue());
}
But it doesn't seem to be recursing properly.
Neil wrote:
> Gavin Doughtie wrote:
>
>> I need to implement something like this, too -- hence my desire for an
>> RDF "recursive node copy". That way, I could just maintain a second
>> in-memory datasource as a clipboard. It's a tricky algorithm because
>> you have to track cycles and not copy nodes twice.
>
>
> Am I missing something? Bad pseudocode follows:
> deep_copy(src, dest, res) {
> enumerate_assertions_from(res);
> foreach (assertion) {
> if (!dest.has(assertion)) {
> dest.assert(assertion);
> deep_copy(src, dest, assertion.target);
function _rdfutils_copyToClipboard( datasource, resource ) {
try {
beanClipboard.flush();
if ((resource||null)!=null)
this.copyResourceToClipboard(datasource,resource,true);
else {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var enumerator = datasource.GetAllResources();
while(enumerator.hasMoreElements()){
this.copyResourceToClipboard( datasource
,enumerator.getNext().QueryInterface(Components.interfaces.nsIRDFResource),f
alse);
}
}
} catch(ex) {
if (log..isErrorEnabled()) log.error("RDFUtils.copyToClipboard " + ex);
}
}
function _rdfutils_copyResourceToClipboard( datasource, resource, recursive)
{
var arcsout = null;
var object = null;
var targets = null;
var arc = null;
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
arcsout = datasource.ArcLabelsOut(resource);
while (arcsout.hasMoreElements()) {
arc =
arcsout.getNext().QueryInterface(Components.interfaces.nsIRDFResource);
targets = datasource.GetTargets(resource,arc,true);
while (targets.hasMoreElements()) {
object=targets.getNext();
try {
beanClipboard.getData().getData().Assert(resource,arc,object,true)
} catch(ex) {
if (application.mnglog.isErrorEnabled())
application.mnglog.error("[RDFUtils.copyResourceToClipboard " +ex);
}
try {
object = object.QueryInterface(Components.interfaces.nsIRDFResource);
if (recursive && !object.EqualsNode(resource))
this.copyResourceToClipboard( datasource, object, recursive)
} catch(ex) {
//if (log..isInfoEnabled())
mnglog.info("RDFUtils.copyResourceToClipboard " + ex );
}
}
}
} catch(ex) {
if (log.isErrorEnabled()) mnglog.error("RDFUtils.copyResourceToClipboard "
+ ex)
}
}
the beanClipboard is an object that container a nsIRDFDataSource, to store
the information
of the clipboard.
"Gavin Doughtie" <gdou...@anim.dreamworks.com> escribió en el mensaje
news:mailman.107533338...@mozilla.org...
Resources don't exist in datasources; they are global objects. A
resource can exist without being used in any datasource.
Datasources contain collections of triples and resources are referred to
by the triples.
I think these may be some good ideas, but there's some problems with
terminology that will lead to APIs that don't make sense.
Some utility functions to move sets of triples from one datasource to
another might be useful. Or to grab a recursive list of children. This
will only work for RDF data that isn't a graph though, unless the
implementation does something to prevent loops.
> I have a primer implementation in javascript, but I think would be
> interesting
> code it in C++, and add an interface like nsIRDFClipboard to access this
> methods.
>
> What do you think?
>
> Thank you all
> Leo.
>
>
/ Neil