use of org.locationtech.geogig.api.ObjectId in project GeoGig by boundlessgeo.
the class RevTreeBuilder2 method putFeature.
public Node putFeature(final ObjectId id, final String name, @Nullable final BoundingBox bounds, final FeatureType type) {
Envelope bbox;
if (bounds == null) {
bbox = null;
} else if (bounds instanceof Envelope) {
bbox = (Envelope) bounds;
} else {
bbox = new Envelope(bounds.getMinimum(0), bounds.getMaximum(0), bounds.getMinimum(1), bounds.getMaximum(1));
}
RevFeatureType revFeatureType = revFeatureTypes.get(type.getName());
if (null == revFeatureType) {
revFeatureType = RevFeatureTypeImpl.build(type);
revFeatureTypes.put(type.getName(), revFeatureType);
}
ObjectId metadataId = revFeatureType.getId().equals(defaultMetadataId) ? ObjectId.NULL : revFeatureType.getId();
Node node = Node.create(name, id, metadataId, TYPE.FEATURE, bbox);
put(node);
return node;
}
use of org.locationtech.geogig.api.ObjectId in project GeoGig by boundlessgeo.
the class LocalMappedRemoteRepo method listRefs.
/**
* List the remote's {@link Ref refs}.
*
* @param getHeads whether to return refs in the {@code refs/heads} namespace
* @param getTags whether to return refs in the {@code refs/tags} namespace
* @return an immutable set of refs from the remote
*/
@Override
public ImmutableSet<Ref> listRefs(final boolean getHeads, final boolean getTags) {
Predicate<Ref> filter = new Predicate<Ref>() {
@Override
public boolean apply(Ref input) {
boolean keep = false;
if (getHeads) {
keep = input.getName().startsWith(Ref.HEADS_PREFIX);
}
if (getTags) {
keep = keep || input.getName().startsWith(Ref.TAGS_PREFIX);
}
return keep;
}
};
ImmutableSet<Ref> remoteRefs = remoteGeoGig.command(ForEachRef.class).setFilter(filter).call();
// Translate the refs to their mapped values.
ImmutableSet.Builder<Ref> builder = new ImmutableSet.Builder<Ref>();
for (Ref remoteRef : remoteRefs) {
Ref newRef = remoteRef;
if (!(newRef instanceof SymRef) && localRepository.graphDatabase().exists(remoteRef.getObjectId())) {
ObjectId mappedCommit = localRepository.graphDatabase().getMapping(remoteRef.getObjectId());
if (mappedCommit != null) {
newRef = new Ref(remoteRef.getName(), mappedCommit);
}
}
builder.add(newRef);
}
return builder.build();
}
use of org.locationtech.geogig.api.ObjectId in project GeoGig by boundlessgeo.
the class AbstractObjectDatabase method putAll.
/**
* This default implementation calls {@link #putInternal(ObjectId, byte[])} for each object;
* subclasses may override if appropriate.
*/
@Override
public void putAll(Iterator<? extends RevObject> objects, final BulkOpListener listener) {
ByteArrayOutputStream rawOut = new ByteArrayOutputStream();
while (objects.hasNext()) {
RevObject object = objects.next();
rawOut.reset();
writeObject(object, rawOut);
final byte[] rawData = rawOut.toByteArray();
final ObjectId id = object.getId();
final boolean added = putInternal(id, rawData);
if (added) {
listener.inserted(object.getId(), rawData.length);
} else {
listener.found(object.getId(), null);
}
}
}
use of org.locationtech.geogig.api.ObjectId in project GeoGig by boundlessgeo.
the class FormatCommonV1 method readBucket.
public static final Bucket readBucket(DataInput in) throws IOException {
final byte[] hash = new byte[20];
in.readFully(hash);
ObjectId objectId = ObjectId.createNoClone(hash);
Envelope bounds = readBBox(in);
return Bucket.create(objectId, bounds);
}
use of org.locationtech.geogig.api.ObjectId in project GeoGig by boundlessgeo.
the class LogOpTest method testSinceUntil.
@Test
public void testSinceUntil() throws Exception {
final ObjectId oid1_1 = insertAndAdd(points1);
final RevCommit commit1_1 = geogig.command(CommitOp.class).call();
insertAndAdd(points2);
final RevCommit commit1_2 = geogig.command(CommitOp.class).call();
insertAndAdd(lines1);
final RevCommit commit2_1 = geogig.command(CommitOp.class).call();
final ObjectId oid2_2 = insertAndAdd(lines2);
final RevCommit commit2_2 = geogig.command(CommitOp.class).call();
try {
logOp = geogig.command(LogOp.class);
logOp.setSince(oid1_1).call();
fail("Expected ISE as since is not a commit");
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().contains("since"));
}
try {
logOp = geogig.command(LogOp.class);
logOp.setSince(null).setUntil(oid2_2).call();
fail("Expected ISE as until is not a commit");
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().contains("until"));
}
List<RevCommit> logs;
List<RevCommit> expected;
logOp = geogig.command(LogOp.class);
logs = toList(logOp.setSince(commit1_2.getId()).setUntil(null).call());
expected = Arrays.asList(commit2_2, commit2_1);
assertEquals(expected, logs);
logOp = geogig.command(LogOp.class);
logs = toList(logOp.setSince(commit2_2.getId()).setUntil(null).call());
expected = Collections.emptyList();
assertEquals(expected, logs);
logOp = geogig.command(LogOp.class);
logs = toList(logOp.setSince(commit1_2.getId()).setUntil(commit2_1.getId()).call());
expected = Arrays.asList(commit2_1);
assertEquals(expected, logs);
logOp = geogig.command(LogOp.class);
logs = toList(logOp.setSince(null).setUntil(commit2_1.getId()).call());
expected = Arrays.asList(commit2_1, commit1_2, commit1_1);
assertEquals(expected, logs);
}
Aggregations