List of usage examples for org.apache.commons.lang.builder Builder build
T build();
From source file:com.galeoconsulting.leonardinius.rest.ErrorCollection.java
/** * Returns a new ErrorCollection containing a single error message. * * @param messages an array of Strings containing error messages * @return a new ErrorCollection//from ww w . j a v a2s.c o m */ public static ErrorCollection of(String... messages) { Builder b = builder(); for (int i = 0; messages != null && i < messages.length; i++) { b.addErrorMessage(messages[i]); } return b.build(); }
From source file:io.horizondb.model.schema.TimeSeriesDefinition.java
/** * Creates a new <code>TimeSeriesMetaData</code> using the specified builder. * // ww w .ja v a2 s . co m * @param builder the builder. */ private TimeSeriesDefinition(Builder builder) { this(builder.name, System.currentTimeMillis(), builder.builder.build(), builder.partitionType, builder.blockSize, builder.compressionType); }
From source file:com.houghtonassociates.bamboo.plugins.GerritRepositoryAdapter.java
protected BuildRepositoryChanges getBuildChangesFromJGit(PlanKey actualKey, String lastVcsRevisionKey) throws RepositoryException { String currentRevision = ""; PersonIdent authorIdent = null;// ww w. j ava2s. c o m BuildRepositoryChanges buildChanges = null; JGitRepository jgitRepo = new JGitRepository(); jgitRepo.setAccessData(gc); jgitRepo.open(this.getSourceCodeDirectory(actualKey)); jgitRepo.openSSHTransport(); currentRevision = jgitRepo.getLatestRevisionForBranch(this.getVcsBranch().getName()); if (!currentRevision.equals(lastVcsRevisionKey)) { String author = Author.UNKNOWN_AUTHOR; try { RevCommit rev = jgitRepo.resolveRev(currentRevision); if (rev != null) { authorIdent = rev.getAuthorIdent(); } } catch (RepositoryException e) { log.debug(String.format("Failed to retrieve author for %s.", currentRevision)); lastVcsRevisionKey = currentRevision; } jgitRepo.close(); if (author.isEmpty() && (authorIdent != null)) author = authorIdent.getName(); Builder cc = CommitContextImpl.builder(); cc.author(author); cc.comment(textProvider.getText("processor.gerrit.messages.build.error.nochanges")); if (authorIdent != null) cc.date(authorIdent.getWhen()); cc.branch(this.getVcsBranch().getName()); cc.changesetId(lastVcsRevisionKey); List<CommitContext> commitlist = Collections.singletonList((CommitContext) cc.build()); buildChanges = new BuildRepositoryChangesImpl(lastVcsRevisionKey, commitlist); } else { buildChanges = new BuildRepositoryChangesImpl(lastVcsRevisionKey); } return buildChanges; }
From source file:org.apache.rya.indexing.smarturi.duplication.DuplicateDataDetectorIT.java
@Test public void testEntitySubjectsDifferent() throws SmartUriException, ConfigurationException { final Entity entity1 = createBobEntity(); final Builder builder = new Builder(entity1); builder.setSubject(createRyaIri("Susan")); final Entity entity2 = builder.build(); final DuplicateDataDetector duplicateDataDetector = new DuplicateDataDetector(); final boolean areDuplicates = duplicateDataDetector.compareEntities(entity1, entity2); assertTrue(areDuplicates);// www. ja v a 2 s . c o m }
From source file:org.apache.rya.indexing.smarturi.duplication.DuplicateDataDetectorIT.java
@Test public void testEntityMissingType() throws SmartUriException, ConfigurationException { final Entity entity1 = createBobEntity(); final Builder builder = new Builder(entity1); builder.setExplicitType(new RyaIRI("urn:example/manager")); final Entity entity2 = builder.build(); final DuplicateDataDetector duplicateDataDetector = new DuplicateDataDetector(); final boolean areDuplicates = duplicateDataDetector.compareEntities(entity1, entity2); assertFalse(areDuplicates);//from w ww . j a va 2s.co m }
From source file:org.apache.rya.indexing.smarturi.duplication.DuplicateDataDetectorIT.java
@Test public void testEntityMissingProperty() throws SmartUriException, ConfigurationException { final Entity entity1 = createBobEntity(); final Builder builder = new Builder(entity1); builder.unsetProperty(PERSON_TYPE_URI, HAS_SSN); final Entity entity2 = builder.build(); final DuplicateDataDetector duplicateDataDetector = new DuplicateDataDetector(); final boolean areDuplicates = duplicateDataDetector.compareEntities(entity1, entity2); assertFalse(areDuplicates);/*from w ww .j a va 2s . co m*/ }
From source file:org.apache.rya.indexing.smarturi.duplication.DuplicateDataDetectorIT.java
@Test public void testCreateEntityNearDuplicate() throws EntityStorageException, TypeStorageException, ObjectStorageException { // Create the types the Entity uses. final TypeStorage typeStorage = new MongoTypeStorage(super.getMongoClient(), RYA_INSTANCE_NAME); final Type personType = createPersonType(); final Type employeeType = createEmployeeType(); typeStorage.create(personType);/*from ww w. ja v a 2s . co m*/ typeStorage.create(employeeType); final Optional<Type> storedPersonType = typeStorage.get(personType.getId()); final Optional<Type> storedEmployeeType = typeStorage.get(employeeType.getId()); assertTrue(storedPersonType.isPresent()); assertTrue(storedEmployeeType.isPresent()); // Create it. final DuplicateDataConfig duplicateDataConfig = new DuplicateDataConfig( new Tolerance(0.0, ToleranceType.DIFFERENCE), // boolean new Tolerance(0.0, ToleranceType.DIFFERENCE), // byte new Tolerance(500.0, ToleranceType.DIFFERENCE), // date new Tolerance(0.0001, ToleranceType.PERCENTAGE), // double new Tolerance(0.0001, ToleranceType.PERCENTAGE), // float new Tolerance(1.0, ToleranceType.DIFFERENCE), // integer new Tolerance(1.0, ToleranceType.DIFFERENCE), // long new Tolerance(1.0, ToleranceType.DIFFERENCE), // short new Tolerance(1.0, ToleranceType.DIFFERENCE), // string new Tolerance(1.0, ToleranceType.DIFFERENCE), // uri new HashMap<String, List<String>>(), true); final DuplicateDataDetector duplicateDataDetector = new DuplicateDataDetector(duplicateDataConfig); final EntityStorage entityStorage = new MongoEntityStorage(super.getMongoClient(), RYA_INSTANCE_NAME, duplicateDataDetector); final Entity bobEntity = createBobEntity(); entityStorage.create(bobEntity); assertTrue(entityStorage.get(bobEntity.getSubject()).isPresent()); final Builder duplicateBobBuilder = Entity.builder(createBobEntity()); duplicateBobBuilder.setSubject(createRyaIri("Robert")); // Modify a property for each type that is within tolerance duplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_AGE, shortRyaType((short) 41))); duplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_WEIGHT, floatRyaType(250.76f))); duplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_HEIGHT, doubleRyaType(72.499))); duplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_INCOME, intRyaType(50001))); duplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_NUMBER_OF_CHILDREN, byteRyaType((byte) 2))); duplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_LICENSE_NUMBER, longRyaType(123456789013L))); duplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_DATE_OF_BIRTH, dateRyaType(new DateTime(NOW.getTime() - 1).minusYears(40)))); duplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_EXPIRATION_DATE, dateRyaType(new Date(NOW.getTime() - 1)))); duplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_GLASSES, booleanRyaType(true))); duplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_EMAIL_ADDRESS, iriRyaType(VF.createIRI("mailto:bob.smitch01@gmail.com")))); duplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_ADDRESS, stringRyaType("124 Fake St. Washington, DC 20024"))); duplicateBobBuilder.setProperty(EMPLOYEE_TYPE_URI, new Property(HAS_EXTENSION, shortRyaType((short) 556))); final Entity duplicateBobEntity = duplicateBobBuilder.build(); // Try to create another entity that's considered a duplicate. // It will NOT be be created. boolean hasDuplicate = false; try { entityStorage.create(duplicateBobEntity); } catch (final EntityNearDuplicateException e) { hasDuplicate = true; } assertTrue(hasDuplicate); assertFalse(entityStorage.get(duplicateBobEntity.getSubject()).isPresent()); final Builder notDuplicateBobBuilder = Entity.builder(createBobEntity()); notDuplicateBobBuilder.setSubject(createRyaIri("Not Bob")); // Modify a property for each type that is within tolerance notDuplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_AGE, shortRyaType((short) 50))); notDuplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_WEIGHT, floatRyaType(300.0f))); notDuplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_HEIGHT, doubleRyaType(100.0))); notDuplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_INCOME, intRyaType(60000))); notDuplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_NUMBER_OF_CHILDREN, byteRyaType((byte) 5))); notDuplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_LICENSE_NUMBER, longRyaType(9L))); notDuplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_DATE_OF_BIRTH, dateRyaType(new DateTime(NOW.getTime() - 10000000L).minusYears(40)))); notDuplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_EXPIRATION_DATE, dateRyaType(new Date(NOW.getTime() - 10000000L)))); notDuplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_GLASSES, booleanRyaType(false))); notDuplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_EMAIL_ADDRESS, iriRyaType(VF.createIRI("mailto:bad.email.address@gmail.com")))); notDuplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_ADDRESS, stringRyaType("123456789 Fake St. Washington, DC 20024"))); notDuplicateBobBuilder.setProperty(EMPLOYEE_TYPE_URI, new Property(HAS_EXTENSION, shortRyaType((short) 1000))); final Entity notDuplicateBobEntity = notDuplicateBobBuilder.build(); // Try to create another entity that's NOT considered a duplicate. // It will be created. try { entityStorage.create(notDuplicateBobEntity); } catch (final EntityNearDuplicateException e) { fail(); } assertTrue(entityStorage.get(notDuplicateBobEntity.getSubject()).isPresent()); }
From source file:org.apache.rya.indexing.smarturi.duplication.DuplicateDataDetectorIT.java
@Test public void testCreateEntityNearDuplicateConfigDisabled() throws EntityStorageException, TypeStorageException, ConfigurationException, ObjectStorageException { // Create the types the Entity uses. final TypeStorage typeStorage = new MongoTypeStorage(super.getMongoClient(), RYA_INSTANCE_NAME); final Type personType = createPersonType(); final Type employeeType = createEmployeeType(); typeStorage.create(personType);//from ww w . j a va 2 s .c om typeStorage.create(employeeType); final Optional<Type> storedPersonType = typeStorage.get(personType.getId()); final Optional<Type> storedEmployeeType = typeStorage.get(employeeType.getId()); assertTrue(storedPersonType.isPresent()); assertTrue(storedEmployeeType.isPresent()); // Create it. final DuplicateDataConfig duplicateDataConfig = new DuplicateDataConfig( new Tolerance(0.0, ToleranceType.DIFFERENCE), // boolean new Tolerance(0.0, ToleranceType.DIFFERENCE), // byte new Tolerance(500.0, ToleranceType.DIFFERENCE), // date new Tolerance(0.0001, ToleranceType.PERCENTAGE), // double new Tolerance(0.0001, ToleranceType.PERCENTAGE), // float new Tolerance(1.0, ToleranceType.DIFFERENCE), // integer new Tolerance(1.0, ToleranceType.DIFFERENCE), // long new Tolerance(1.0, ToleranceType.DIFFERENCE), // short new Tolerance(1.0, ToleranceType.DIFFERENCE), // string new Tolerance(1.0, ToleranceType.DIFFERENCE), // uri new HashMap<String, List<String>>(), false); final DuplicateDataDetector duplicateDataDetector = new DuplicateDataDetector(duplicateDataConfig); final EntityStorage entityStorage = new MongoEntityStorage(super.getMongoClient(), RYA_INSTANCE_NAME, duplicateDataDetector); final Entity bobEntity = createBobEntity(); entityStorage.create(bobEntity); assertTrue(entityStorage.get(bobEntity.getSubject()).isPresent()); final Builder duplicateBobBuilder = Entity.builder(createBobEntity()); duplicateBobBuilder.setSubject(createRyaIri("Robert")); // Modify a property for each type that is within tolerance duplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_AGE, shortRyaType((short) 41))); duplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_WEIGHT, floatRyaType(250.76f))); duplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_HEIGHT, doubleRyaType(72.499))); duplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_INCOME, intRyaType(50001))); duplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_NUMBER_OF_CHILDREN, byteRyaType((byte) 2))); duplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_LICENSE_NUMBER, longRyaType(123456789013L))); duplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_DATE_OF_BIRTH, dateRyaType(new DateTime(NOW.getTime() - 1).minusYears(40)))); duplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_EXPIRATION_DATE, dateRyaType(new Date(NOW.getTime() - 1)))); duplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_GLASSES, booleanRyaType(true))); duplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_EMAIL_ADDRESS, iriRyaType(VF.createIRI("mailto:bob.smitch01@gmail.com")))); duplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_ADDRESS, stringRyaType("124 Fake St. Washington, DC 20024"))); duplicateBobBuilder.setProperty(EMPLOYEE_TYPE_URI, new Property(HAS_EXTENSION, shortRyaType((short) 556))); final Entity duplicateBobEntity = duplicateBobBuilder.build(); // Try to create another entity that's considered a duplicate. // Data duplication detection is disabled so it will be created. try { entityStorage.create(duplicateBobEntity); } catch (final EntityNearDuplicateException e) { fail(); } assertTrue(entityStorage.get(duplicateBobEntity.getSubject()).isPresent()); final Builder notDuplicateBobBuilder = Entity.builder(createBobEntity()); notDuplicateBobBuilder.setSubject(createRyaIri("Not Bob")); // Modify a property for each type that is within tolerance notDuplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_AGE, shortRyaType((short) 50))); notDuplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_WEIGHT, floatRyaType(300.0f))); notDuplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_HEIGHT, doubleRyaType(100.0))); notDuplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_INCOME, intRyaType(60000))); notDuplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_NUMBER_OF_CHILDREN, byteRyaType((byte) 5))); notDuplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_LICENSE_NUMBER, longRyaType(9L))); notDuplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_DATE_OF_BIRTH, dateRyaType(new DateTime(NOW.getTime() - 10000000L).minusYears(40)))); notDuplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_EXPIRATION_DATE, dateRyaType(new Date(NOW.getTime() - 10000000L)))); notDuplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_GLASSES, booleanRyaType(false))); notDuplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_EMAIL_ADDRESS, iriRyaType(VF.createIRI("mailto:bad.email.address@gmail.com")))); notDuplicateBobBuilder.setProperty(PERSON_TYPE_URI, new Property(HAS_ADDRESS, stringRyaType("123456789 Fake St. Washington, DC 20024"))); notDuplicateBobBuilder.setProperty(EMPLOYEE_TYPE_URI, new Property(HAS_EXTENSION, shortRyaType((short) 1000))); final Entity notDuplicateBobEntity = notDuplicateBobBuilder.build(); // Try to create another entity that's NOT considered a duplicate. // Data duplication detection is disabled so it will be created. try { entityStorage.create(notDuplicateBobEntity); } catch (final EntityNearDuplicateException e) { fail(); } assertTrue(entityStorage.get(notDuplicateBobEntity.getSubject()).isPresent()); }
From source file:org.apache.rya.indexing.smarturi.duplication.DuplicateDataDetectorIT.java
/** * Creates two entities to test where one property is different from the * other. Multiple different values for the property are provided by * {@code testInputs}.//from w w w .j a v a 2s.c o m * @param testInputs the {@link List} of {@link TestInput} to insert into * the property. * @param typeIdUri the type ID {@link RyaIRI} that the property falls * under. (not {@code null}) * @param propertyNameUri the property name {@link RyaIRI}. * (not {@code null}) * @param equivalentTermsMap the {@link Map} of terms that are considered * equivalent to each other. * @throws SmartUriException */ private static void testProperty(final List<TestInput> testInputs, final RyaIRI typeIdUri, final RyaIRI propertyNameUri, final Map<String, List<String>> equivalentTermsMap) throws SmartUriException { requireNonNull(typeIdUri); requireNonNull(propertyNameUri); final Entity entity1 = createBobEntity(); int count = 0; for (final TestInput testInput : testInputs) { System.out.println("Test #" + count + ": " + testInput.toString()); final Object testValue = testInput.getValue(); final Tolerance tolerance = testInput.getTolerance(); final boolean expected = testInput.getExpected(); final Builder builder = new Builder(entity1); final RyaType ryaType = RyaTypeUtils.getRyaTypeForClass(testValue.getClass(), testValue); builder.setProperty(typeIdUri, new Property(propertyNameUri, ryaType)); final Entity entity2 = builder.build(); final DuplicateDataDetector duplicateDataDetector = new DuplicateDataDetector(tolerance, equivalentTermsMap); final boolean areDuplicates = duplicateDataDetector.compareEntities(entity1, entity2); final String originalValue = entity1.lookupTypeProperty(typeIdUri, propertyNameUri).get().getValue() .getData(); final String message = createErrorMessage(originalValue, testValue, expected, areDuplicates, tolerance); assertEquals(message, expected, areDuplicates); count++; } }
From source file:org.apache.rya.indexing.smarturi.duplication.DuplicateDataDetectorTest.java
@Test public void testEntitySubjectsDifferent() throws SmartUriException, ConfigurationException { final Entity entity1 = createBobEntity(); final Builder builder = new Builder(entity1); builder.setSubject(createRyaUri("Susan")); final Entity entity2 = builder.build(); final DuplicateDataDetector duplicateDataDetector = new DuplicateDataDetector(); final boolean areDuplicates = duplicateDataDetector.compareEntities(entity1, entity2); assertTrue(areDuplicates);/*from w ww . j a v a 2 s. co m*/ }