Skip to content

Commit

Permalink
write index for new link contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
peacekeeper committed Oct 14, 2015
1 parent 8fe481a commit e1ccb19
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@
import xdi2.client.manipulator.impl.SetLinkContractMessageManipulator;
import xdi2.core.ContextNode;
import xdi2.core.Graph;
import xdi2.core.constants.XDILinkContractConstants;
import xdi2.core.features.index.Index;
import xdi2.core.features.linkcontracts.LinkContractTemplates;
import xdi2.core.features.linkcontracts.instance.LinkContract;
import xdi2.core.features.linkcontracts.instance.PublicLinkContract;
import xdi2.core.features.linkcontracts.instantiation.LinkContractInstantiation;
import xdi2.core.features.linkcontracts.template.LinkContractTemplate;
import xdi2.core.features.nodetypes.XdiEntityCollection;
import xdi2.core.features.nodetypes.XdiEntitySingleton;
import xdi2.core.features.nodetypes.XdiInnerRoot;
import xdi2.core.syntax.XDIAddress;
Expand Down Expand Up @@ -249,15 +252,17 @@ private void processConnect(LinkContractTemplate linkContractTemplate, Operation

LinkContract linkContract = linkContractInstantiation.execute(instanceXDIArc, true);

// write link contract into operation result graph
// write link contract and index into operation result graph

CopyUtil.copyGraph(linkContract.getContextNode().getGraph(), operationResultGraph, null);

// link contract into target graph
// write link contract and index into target graph

if (this.getTargetGraph() != null) {

CopyUtil.copyGraph(linkContract.getContextNode().getGraph(), this.getTargetGraph(), null);
XdiEntityCollection xdiLinkContractIndex = Index.getEntityIndex(this.getTargetGraph(), XDILinkContractConstants.XDI_ARC_DO, true);
Index.setEntityIndexAggregation(xdiLinkContractIndex, linkContract.getXdiEntity());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
import org.slf4j.LoggerFactory;

import xdi2.core.Graph;
import xdi2.core.constants.XDILinkContractConstants;
import xdi2.core.features.index.Index;
import xdi2.core.features.linkcontracts.instance.LinkContract;
import xdi2.core.features.nodetypes.XdiEntityCollection;
import xdi2.core.features.nodetypes.XdiInnerRoot;
import xdi2.core.syntax.XDIAddress;
import xdi2.core.util.CopyUtil;
Expand Down Expand Up @@ -170,13 +173,15 @@ private void processPush(Message pushedMessage, Operation operation, Graph opera
// TODO: use feedback message? or have member field private Graph targetGraph; ?
// TODO: or have the XDIClient put it into our "origin" graph by adding a originGraph parameter to XDIClient?

if ((executionContext.getCurrentMessagingTarget() instanceof GraphMessagingTarget)) {
// write link contract and index into target graph

GraphMessagingTarget graphMessagingTarget = ((GraphMessagingTarget) executionContext.getCurrentMessagingTarget());
if (this.getTargetGraph() != null) {

for (LinkContract pushLinkContract : pushMessagingResponse.getPushLinkContracts()) {

CopyUtil.copyContextNode(pushLinkContract.getContextNode(), graphMessagingTarget.getGraph(), null);
CopyUtil.copyContextNode(pushLinkContract.getContextNode(), this.getTargetGraph(), null);
XdiEntityCollection xdiLinkContractIndex = Index.getEntityIndex(this.getTargetGraph(), XDILinkContractConstants.XDI_ARC_DO, true);
Index.setEntityIndexAggregation(xdiLinkContractIndex, pushLinkContract.getXdiEntity());
}
}
}
Expand Down

0 comments on commit e1ccb19

Please sign in to comment.