/** * {@inheritDoc} */ @Override public PropertyHelper property(URI propertyId) { return this.iHelper.property(propertyId); }
/** * {@inheritDoc} */ @Override public PropertyHelper property(String propertyId) { return this.iHelper.property(propertyId); }
/** * {@inheritDoc} */ @Override public PropertyHelper property(Term property) { return this.iHelper.property(property); }
public <T> T literal(final String propertyURI, final Class<? extends T> aClazz) { return this.helper. property(propertyURI). firstValue(aClazz); }
public Optional<URI> individual(final String propertyURI) { return Optional. fromNullable( this.helper. property(propertyURI). firstIndividual(ExternalIndividual.class)); }
private void addInferredTypes() { final PropertyHelper property=this.helper.property(RDF.TYPE); for(final String type:this.inferredTypes) { property.withIndividual(type); } }
private void addExternalIndividual(final URI externalIndividual) { this.item.property(this.property).withIndividual(externalIndividual); }
private void populateTags(final Issue issue, final IndividualHelper individual) { for(final String tag:issue.getTags()) { individual. property(IT.ISSUE_CUSTOM_TAG). withLiteral(tag); } }
private <V> void addLiteral(final AbstractItem<V> aItem) { this.item.property(this.property).withLiteral(getValue(aItem)); }
public Mapper individualMapper(final String propertyURI) { return new Mapper(this.helper.property(propertyURI).firstIndividual()); }
private void addRelations(final String relation, final Collection<? extends K> elements) { final String managerId=managerId(); final PropertyHelper property=this.helper.property(relation); for(final K key:elements){ property.withIndividual(createName(key),managerId); } }
private void populateChangeLogEntry(final Issue issue, final Entry entryData, final Name<String> entryName, final DataSetHelper helper, final IndividualHelper changeLog) { final IndividualHelper entry = helper. localIndividual(entryName); changeLog. property(IT.HAS_CHANGE_LOG_ENTRY). withIndividual(entryName); entry. property(RDF.TYPE). withIndividual(IT.CHANGE_LOG_ENTRY_TYPE). property(IT.ENTRY_TIME_STAMP). withLiteral(entryData.getTimeStamp()); /** * TODO: Should fail if no author is defined */ new ContributorLinker(entry). link(IT.TRIGGERED_BY,entryData.getAuthor()); int itemCount=0; for(final Item item:entryData.getItems()) { final Name<String> itemName=NamingScheme.getDefault().name(entryName.id(),"item",Integer.toString(itemCount++)); populateChangeLogItem(issue,item, itemName, helper, changeLog, entry); } }
private void populateChangeLog(final Issue issue, final Name<String> changeLogName, final DataSetHelper helper) { final IndividualHelper changeLog = helper. localIndividual(changeLogName). property(RDF.TYPE). withIndividual(IT.CHANGE_LOG_TYPE); if(issue.getChanges()==null) { return; } int entryCount=0; for(final Entry entry:issue.getChanges().getEntries()) { final Name<String> entryName= NamingScheme. getDefault(). name( changeLogName.id(), "entry", Integer.toString(entryCount++)); populateChangeLogEntry(issue,entry,entryName,helper,changeLog); } }
@Test public void testDataDSL() { Date date=new Date(); Name<String> name = NamingScheme.getDefault().name("name"); DataSet initialData = getInitialData(TEMPLATE_ID,name.id(),false,date); DataSetHelper helper=DataSetUtils.newHelper(initialData); DateTime firstValue= helper. managedIndividual(name,TEMPLATE_ID). property(READ_ONLY_PROPERTY). firstValue(DateTime.class); assertThat(firstValue,notNullValue()); assertThat(TimeUtils.newInstance().from(firstValue).toDate(),equalTo(date)); }
@Test public void testIndividualHelperCreation() { DataSet data=exampleDataSet(); Individual<?,?> individual = data.individualOfId(BLANK_NODE); DataSetUtils.newHelper(individual).property(RDFS.LABEL).withLiteral("My label"); assertThat(individual.property(RDFS.LABEL.as(URI.class)).hasLiteralValue(Literals.of("My label")),equalTo(true)); }
@Override protected DataSet toDataSet(final Contributor contributor, final String contributorId) { final Name<String> contributorName=IdentityUtil.contributorName(contributorId); final DataSet dataSet=DataSets.createDataSet(contributorName); final DataSetHelper helper=DataSetUtils.newHelper(dataSet); final IndividualPropertyHelper individual= helper. managedIndividual(contributorName,ContributorHandler.ID). property(RDF.TYPE). withIndividual(IT.CONTRIBUTOR_TYPE). property(IT.ID). withLiteral(contributor.getId()). property(IT.CONTRIBUTOR_ID). withLiteral(contributor.getId()). property(IT.CONTRIBUTOR_NAME). withLiteral(contributor.getName()); for(final String email:contributor.getEmails()) { individual. property(IT.MBOX). withLiteral(URI.create(email)); } return dataSet; }
@Override public DataSet get(final ResourceSnapshot resource) { final DataSet dataSet=DataSets.createDataSet(resource.name()); final DataSetHelper helper=DataSetUtils.newHelper(dataSet); helper. managedIndividual(resource.name(), ID). property(RDF.TYPE). withIndividual(DCTYPE.SERVICE_TYPE). withIndividual(PLATFORM.MICRO_SERVICE_TYPE). withIndividual(PLATFORM.LINKED_DATA_MICRO_SERVICE_TYPE). withIndividual(PLATFORM.HARVESTER_TYPE). withIndividual(IT.HARVESTER_TYPE). property(PLATFORM.HARVESTER_VOCABULARY). withIndividual(resource.name(),HarvesterHandler.ID,VOCABULARY_PATH); helper. relativeIndividual(resource.name(),HarvesterHandler.ID,VOCABULARY_PATH). property(RDF.TYPE). withIndividual(IT.VOCABULARY_TYPE). withIndividual(PLATFORM.VOCABULARY_TYPE). property(PLATFORM.SOURCE). withLiteral(IT.sourceCode()). property(DCTERMS.SOURCE). withLiteral(IT.sourceCode()). property(PLATFORM.IMPLEMENTS). withIndividual(IT.DOMAIN_TYPE); return dataSet; }
@Override protected DataSet toDataSet(final Commit commit, final String commitId) { final Name<String> commitName=IdentityUtil.commitName(commitId); final DataSet dataSet=DataSets.createDataSet(commitName); final DataSetHelper helper=DataSetUtils.newHelper(dataSet); helper. managedIndividual(commitName,CommitHandler.ID). property(RDF.TYPE). withIndividual(IT.COMMIT_TYPE). property(IT.ID). withLiteral(commit.getId()). property(IT.COMMIT_ID). withLiteral(commit.getId()). property(IT.REPOSITORY). withLiteral(URI.create(commit.getRepository())). property(IT.BRANCH). withLiteral(commit.getBranch()). property(IT.HASH). withLiteral(commit.getHash()); return dataSet; }
@Override protected DataSet toDataSet(final Version version, final VersionKey key) { final Name<VersionKey> versionName=IdentityUtil.versionName(key); final DataSet dataSet=DataSets.createDataSet(versionName); final DataSetHelper helper=DataSetUtils.newHelper(dataSet); helper. managedIndividual(versionName,VersionHandler.ID). property(RDF.TYPE). withIndividual(IT.VERSION_TYPE). property(IT.ID). withLiteral(version.getId()). property(PLATFORM.NAME). withLiteral(version.getName()). property(IT.VERSION_NAME). withLiteral(version.getName()). property(IT.VERSION_ID). withLiteral(version.getId()); return dataSet; }
@Override protected DataSet toDataSet(final Component component, final ComponentKey key) { final Name<ComponentKey> componentName=IdentityUtil.componentName(key); final DataSet dataSet=DataSets.createDataSet(componentName); final DataSetHelper helper=DataSetUtils.newHelper(dataSet); helper. managedIndividual(componentName,ComponentHandler.ID). property(RDF.TYPE). withIndividual(IT.COMPONENT_TYPE). property(IT.ID). withLiteral(component.getId()). property(IT.COMPONENT_ID). withLiteral(component.getId()). property(DCTERMS.TITLE). withLiteral(component.getName()). property(IT.COMPONENT_TITLE). withLiteral(component.getName()); return dataSet; }