@Test public void testCreatesManagedIndividualIfItDoesNotExist() throws Exception { DataSet dataSet = exampleDataSet(); DataSetUtils. newHelper(dataSet). managedIndividual(name("other"),MANAGER_ID); Individual<?,?> individual = dataSet. individualOfId(managedIndividualId("other", MANAGER_ID)); assertThat(individual,notNullValue()); }
@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)); }
@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 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; }
managedIndividual(serviceName, ServiceHandler.ID). property(TYPE). withIndividual(DC_TYPE_SERVICE_TYPE).
@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; }
@Override protected DataSet toDataSet(final Project project, final String repositoryId) { final Name<String> projectName=IdentityUtil.projectName(repositoryId); final DataSet dataSet=DataSets.createDataSet(projectName); final DataSetHelper helper=DataSetUtils.newHelper(dataSet); final IndividualPropertyHelper individual = helper. managedIndividual(projectName,ProjectHandler.ID). property(RDF.TYPE). withIndividual(IT.PROJECT_TYPE). property(IT.ID). withLiteral(project.getId()). property(IT.PROJECT_ID). withLiteral(project.getId()). property(DCTERMS.TITLE). withLiteral(project.getName()). property(IT.PROJECT_TITLE). withLiteral(project.getName()); for(final String issueId:project.getTopIssues()) { final Name<IssueKey> issueName= IdentityUtil. issueName( new IssueKey(project.getId(),issueId)); individual. property(IT.HAS_PROJECT_TOP_ISSUE). withIndividual(issueName,IssueHandler.ID); } return dataSet; }
managedIndividual(issueName,IssueHandler.ID). property(RDF.TYPE). withIndividual(IT.ISSUE_TYPE).
@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; }
DataSetHelper helper = DataSetUtils.newHelper(dataSet); helper. managedIndividual(name("unknown"),"managerId"). property(RDFS.LABEL). withLiteral("label").
managedIndividual(buildName, BuildHandler.ID). property(TYPE). withIndividual(AUTOMATION_PLAN).
final IndividualPropertyHelper executionHelper = helper. managedIndividual(executionName,ExecutionHandler.ID). property(TYPE). withIndividual(AUTO_AUTOMATION_REQUEST).
DataSetHelper helper = DataSetUtils.newHelper(dataSet); helper. managedIndividual(RESOURCE_NAME, MANAGER_ID). property(HAS_TITLE). withLiteral("managed").