/** * List all features in the repository with the given name at the provided ref. * * @param headRef the ref from which to list the features * @param index {@code true} if the {@code headRef} parameter refers to an index tree * @return a multimap that contains all of the feature types and their features */ public SetMultimap<String, String> listRepo(final String headRef, final boolean index) { Context context = geogigCLI.getGeogig().getContext(); ObjectStore source = index ? context.indexDatabase() : context.objectDatabase(); Iterator<NodeRef> featureRefs = context.command(LsTreeOp.class).setReference(headRef) .setStrategy(Strategy.DEPTHFIRST_ONLY_FEATURES).setSource(source).call(); SetMultimap<String, String> features = HashMultimap.create(); while (featureRefs.hasNext()) { NodeRef ref = featureRefs.next(); features.put(index ? "index" : ref.getParentPath(), ref.name()); } return features; } }
/** * List all features in the repository with the given name at the provided ref. * * @param headRef the ref from which to list the features * @param index {@code true} if the {@code headRef} parameter refers to an index tree * @return a multimap that contains all of the feature types and their features */ public SetMultimap<String, String> listRepo(final String headRef, final boolean index) { Context context = geogigCLI.getGeogig().getContext(); ObjectStore source = index ? context.indexDatabase() : context.objectDatabase(); Iterator<NodeRef> featureRefs = context.command(LsTreeOp.class).setReference(headRef) .setStrategy(Strategy.DEPTHFIRST_ONLY_FEATURES).setSource(source).call(); SetMultimap<String, String> features = HashMultimap.create(); while (featureRefs.hasNext()) { NodeRef ref = featureRefs.next(); features.put(index ? "index" : ref.getParentPath(), ref.name()); } return features; } }
/** * List all features in the repository with the given name at the provided ref. * * @param headRef the ref from which to list the features * @param index {@code true} if the {@code headRef} parameter refers to an index tree * @return a multimap that contains all of the feature types and their features */ public SetMultimap<String, String> listRepo(final String headRef, final boolean index) { Context context = geogigCLI.getGeogig().getContext(); ObjectStore source = index ? context.indexDatabase() : context.objectDatabase(); Iterator<NodeRef> featureRefs = context.command(LsTreeOp.class).setReference(headRef) .setStrategy(Strategy.DEPTHFIRST_ONLY_FEATURES).setSource(source).call(); SetMultimap<String, String> features = HashMultimap.create(); while (featureRefs.hasNext()) { NodeRef ref = featureRefs.next(); features.put(index ? "index" : ref.getParentPath(), ref.name()); } return features; } }
/** * List all features in the repository with the given name at the provided ref. * * @param repoName the repository to list the features for * @param headRef the ref from which to list the features * @param txId the transaction that the tree is on * @param index {@code true} if the {@code headRef} parameter refers to an index tree * @return a multimap that contains all of the feature types and their features */ public SetMultimap<String, String> listRepo(final String repoName, final String headRef, final String txId, final boolean index) { Context context = getRepo(repoName).context(); if (txId != null) { context = context.command(TransactionResolve.class) .setId(UUID.fromString(getVariable(txId))).call().get(); } ObjectStore source = index ? context.indexDatabase() : context.objectDatabase(); Iterator<NodeRef> featureRefs = context.command(LsTreeOp.class).setReference(headRef) .setStrategy(Strategy.DEPTHFIRST_ONLY_FEATURES).setSource(source).call(); SetMultimap<String, String> features = HashMultimap.create(); while (featureRefs.hasNext()) { NodeRef ref = featureRefs.next(); features.put(index ? "index" : ref.getParentPath(), ref.name()); } return features; }
public static void verifyIndex(Context context, ObjectId indexTreeId, ObjectId canonicalTreeId, String... extraAttributes) { Iterator<NodeRef> canonicalFeatures = context.command(LsTreeOp.class) .setReference(canonicalTreeId.toString()) .setStrategy(Strategy.DEPTHFIRST_ONLY_FEATURES).call(); Iterator<NodeRef> indexFeatures = context.command(LsTreeOp.class) .setReference(indexTreeId.toString()).setStrategy(Strategy.DEPTHFIRST_ONLY_FEATURES) .setSource(context.indexDatabase()).call(); List<NodeRef> canonicalFeaturesList = Lists.newArrayList(canonicalFeatures); while (indexFeatures.hasNext()) { NodeRef indexFeature = indexFeatures.next(); if (extraAttributes.length > 0) { Map<String, Object> featureExtraData = indexFeature.getNode().getExtraData(); assertNotNull("Node has no extra data: " + indexFeature.getNode(), featureExtraData); Map<String, Object> featureExtraAttributes = IndexInfo .getMaterializedAttributes(indexFeature.getNode()); assertEquals(extraAttributes.length, featureExtraAttributes.size()); for (String attribute : extraAttributes) { assertTrue(featureExtraAttributes.containsKey(attribute)); featureExtraAttributes.remove(attribute); } assertTrue(featureExtraAttributes.isEmpty()); } assertTrue(canonicalFeaturesList.contains(indexFeature)); canonicalFeaturesList.remove(indexFeature); } assertTrue(canonicalFeaturesList.isEmpty()); }
public static void verifyIndex(Context context, ObjectId indexTreeId, ObjectId canonicalTreeId, String... extraAttributes) { Iterator<NodeRef> canonicalFeatures = context.command(LsTreeOp.class) .setReference(canonicalTreeId.toString()).setStrategy(Strategy.DEPTHFIRST_ONLY_FEATURES) .call(); Iterator<NodeRef> indexFeatures = context.command(LsTreeOp.class) .setReference(indexTreeId.toString()).setStrategy(Strategy.DEPTHFIRST_ONLY_FEATURES) .setSource(context.indexDatabase()).call(); List<NodeRef> canonicalFeaturesList = Lists.newArrayList(canonicalFeatures); while (indexFeatures.hasNext()) { NodeRef indexFeature = indexFeatures.next(); if (extraAttributes.length > 0) { Map<String, Object> featureExtraData = indexFeature.getNode().getExtraData(); assertNotNull("Node has no extra data: " + indexFeature.getNode(), featureExtraData); Map<String, Object> featureExtraAttributes = IndexInfo .getMaterializedAttributes(indexFeature.getNode()); assertEquals(extraAttributes.length, featureExtraAttributes.size()); for (String attribute : extraAttributes) { assertTrue(featureExtraAttributes.containsKey(attribute)); featureExtraAttributes.remove(attribute); } assertTrue(featureExtraAttributes.isEmpty()); } assertTrue(canonicalFeaturesList.contains(indexFeature)); canonicalFeaturesList.remove(indexFeature); } assertTrue(canonicalFeaturesList.isEmpty()); }