Represent relation between services in SOAF - foaf

I have some problem about SOAF; service of a friend (extension of FOAF).
I want to create a SOAF file like this:
<foaf:knows>
<soaf:Connection>
<soaf:established>December 1 s t 2008</soaf:established>
<soaf:discontinued>December 21 s t 2008</soaf:discontinued>
<soaf:active>false</soaf:active>
<soaf:connectiontype>Cont inuous</soaf:connectiontype>
<soaf:uses>
<soaf:Service>
<foaf:name>SOAFReporter</foaf:name>
. . .
</soaf:Service>
</soaf:uses>
</soaf:Connection>
</foaf:knows>
In this file, soaf:uses represents the relation between person and services.
In SOAF model, we can represent also the relation between services "services uses services".
I want in my new SOAF file to represent this relation, but I don't know how and I don't find any example.

You can represent the relation Service A uses Service B like this:
<soaf:Service>
<foaf:name>Service A</foaf:name>
<foaf:knows>
<soaf:Connection>
<soaf:established>December 1 st 2008</soaf:established>
<soaf:discontinued>December 21 st 2008</soaf:discontinued>
<soaf:active>false</soaf:active>
<soaf:connectiontype>Continuous</soaf:connectiontype>
<soaf:uses>
<soaf:Service>
<foaf:name>Service B</foaf:name>
. . .
</soaf:Service>
</soaf:uses>
</soaf:Connection>
</foaf:knows>
</soaf:Service>
Of course, you can also add several connection objects (these encapsulate the actual relation) in the knows relation.

Related

How does a triplestore decide whether to add "background" triples?

I use a few different triplestores, and code in R and Scala. I think I'm seeing some differences in:
whether the triplestores include triples other than the ones I
explicitly loaded.
the point at which these "background" triples might be added.
Are there any general rules for whether supporting vocabularies need to be added, independent of the implementation technology?
Using Jena in R, via rrdf, I usually only see what I loaded:
library(rrdf)
turtle.input.string <-
"PREFIX prefix: <http://example.com/>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix:subject rdf:type prefix:object"
jena.model <-
fromString.rdf(rdfContent = turtle.input.string, format = "TURTLE")
model.string <- asString.rdf(jena.model, format = "TURTLE")
cat(model.string)
This gives:
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix prefix: <http://example.com/> .
prefix:subject a prefix:object .
But sometimes triples from RDF and RDFS seems to appear when I add or remove triples afterwards. That's what "bothers" me the most, but I'm having trouble finding an example right now. If nobody knows what I mean, I'll dig something up later today.
When I use Blazegraph in Scala, via the OpenRDF Sesame library, I think I always get RDF, RDFS, and OWL "for free"
import java.util.Properties
import org.openrdf.query.QueryLanguage
import org.openrdf.rio._
import com.bigdata.journal._
import com.bigdata.rdf.sail._
object InjectionTest {
val jnl_fn = "sparql_tests.jnl"
def main(args: Array[String]): Unit = {
val props = new Properties()
props.put(Options.BUFFER_MODE, BufferMode.DiskRW)
props.put(Options.FILE, jnl_fn)
val sail = new BigdataSail(props)
val repo = new BigdataSailRepository(sail)
repo.initialize()
val cxn = repo.getConnection()
val resultStream = new java.io.ByteArrayOutputStream
val resultWriter = Rio.createWriter(RDFFormat.TURTLE, resultStream)
val ConstructString = "construct {?s ?p ?o} where {?s ?p ?o}"
cxn.prepareGraphQuery(QueryLanguage.SPARQL, ConstructString).evaluate(resultWriter)
var resString = resultStream.toString()
println(resString)
}
}
Even without adding any triples, the construct output includes blocks like this:
rdfs:isDefinedBy rdfs:domain rdfs:Resource ;
rdfs:range rdfs:Resource ;
rdfs:subPropertyOf rdfs:isDefinedBy , rdfs:seeAlso .
Are there any general rules for whether supporting vocabularies need to be added, independent of the implementation technology?
That depends on what inferencing scheme your triplestore claims to support. For a pure RDF store (no inferencing), no additional triples should be added at all.
Judging from that fragment you showed, the Blazegraph store you used has at least RDFS inferencing (and possibly partial OWL reasoning as well?) enabled. Note that this is store-specific, not framework, so it's not a Jena vs. Sesame thing: both frameworks support stores that either do or do not do reasoning. Of course, if you use either framework and use the "excluded inferred triples" option that they offer, the backing store should respect that config option and not include such inferred triples in the result.

Cypher: how to navigate graph to find the right path

I'm new to Cypher, I'm trying to learn to navigate a graph correctly.
I hava a situation like this: 2 Users have associated the same Service, the service is accessible via an Account. So, the user 'usr01' can access to the Service 'srv01' with account 'acct01'; the user 'usr02 can access to the Service 'srv01' with account 'acct02'.
The aim is to extract 2 records like this:
usr01 - srv01 - acct01
usr02 - srv01 - acct02
So, I executed these queries:
Creation of nodes:
create (s:XService {serviceId:'srv01'}) return s;
create (u:XUser {userId:'usr01'}) return u;
create (u:XUser {userId:'usr02'}) return u;
create (u:XAccount {accountId:'acct01'}) return u;
create (u:XAccount {accountId:'acct02'}) return u;
Relationship creation:
MATCH (u:XUser{userId:'usr01'}), (s:XService {serviceId:'srv01'}), (a:XAccount {accountId:'acct01'})
CREATE (u)-[:HAS_SERVICE]->(s)-[:HAS_ACCOUNT]->(a)
MATCH (u:XUser{userId:'usr02'}), (s:XService {serviceId:'srv01'}), (a:XAccount {accountId:'acct02'})
CREATE (u)-[:HAS_SERVICE]->(s)-[:HAS_ACCOUNT]->(a)
The graph result I've received is this
If I execute this query - starting from the user usr01:
MATCH (u:XUser {userId: 'usr01'}) OPTIONAL MATCH (u)-[:HAS_SERVICE]->(s:XService) OPTIONAL MATCH (s)-[:HAS_ACCOUNT]->(a:XAccount)
RETURN u.userId, s.serviceId, a.accountId;
I obtain this result:
So, how can I do to obtain the result described above (usr01 - srv01 - acct01) and not the cartesian product that I've received?
Thanks in advance
The problem is that when you add the relationship between the service and the account you do not indicate an association relationship with the user. As a solution, you can make a smart node "Access Rule":
MERGE (s:XService {serviceId:'srv01'})
MERGE (u1:XUser {userId:'usr01'})
MERGE (ua1:XAccount {accountId:'acct01'})
MERGE (u1)-[:can_access]->(ca1:AccessRule)-[:to_service]->(s)
MERGE (ca1)-[:with_account]->(ua1)
MERGE (u2:XUser {userId:'usr02'})
MERGE (ua2:XAccount {accountId:'acct02'})
MERGE (u2)-[:can_access]->(ca2:AccessRule)-[:to_service]->(s)
MERGE (ca2)-[:with_account]->(ua2)
And a query:
MATCH (u:XUser {userId: 'usr01'})
OPTIONAL MATCH ps = (u)-[:can_access]->(ca1:AccessRule)-[:to_service]->(s:XService)
OPTIONAL MATCH pa = (ca1)-[:with_account]->(a:XAccount)
RETURN u, ps, pa

Getting the level x value of the currentmember in a parent-child hierarchy in MDX

I have an employee parent-child hierarchy in a dimension called Employees which shows the managerial structure of an organisation. This hierarchy is [Employees].[Managerial].
There is another hierarchy that lists all the employees for an organisation. This is a single level hierarchy and it is [Employess].[All Employees].
I have a query that looks something like this:
With
Member measures.[FullTimeSalary] as measures.[Salary] * measures.[FullTimeFactor]
Select {measures.[FullTimeSalary]} on 0,
Non empty
{
[Employess].[All Employees].[All].Children
}
On 1
From MyCube
Where ([Time].[Month].&[201501])
Now if I expand the parent-child hierarchy (the [Employees].[Managerial] hierarchy) I can see each of the different levels of this structure( [Level 02], [Level 03], [Level 04], ect) and what I need to do now is create a new calculated measure called measures.[SupervisingManager] that brings back the currentmembers value at [Level 03] of the hierarchy.
I've tried
member measures.[SupervisingManager] as [Employees].[Managerial].[Level 03].currentmember.member_name
but that just returns "#Error" and using
member measures.[SupervisingManager] as [Employees].[Managerial].currentmember.member_name
returns that currentmember. I also experimented with
measures.[SupervisingManager] as [Employees].[Managerial].currentmember.parent.member_name
but the issue with this is that the currentmember can be located at any within the hierarchy. The only way I can think of doing this is to do a massive case statement, get the ordinal value of the current member and use the appropriate .parent.parent logic. Is there a neater way to do this?
Maybe something along these lines will help:
WITH
MEMBER measures.[FullTimeSalary] AS
measures.[Salary] * measures.[FullTimeFactor]
MEMBER measures.[SupervisingManager] AS
IIF
(
[Employees].CurrentMember.Parent.Level.Name = 'Level 03'
,[Employees].CurrentMember.Parent.Member_Caption
,'n/a'
)
SELECT
{
measures.[FullTimeSalary]
,measures.[SupervisingManager]
} ON 0
,NON EMPTY
{[Employess].[All Employees].[All].Children} ON 1
FROM MyCube
WHERE
[Time].[Month].&[201501];

AX 2009: Adjusting User Group Length

We're looking into refining our User Groups in Dynamics AX 2009 into more precise and fine-tuned groupings due to the wide range of variability between specific people within the same department. With this plan, it wouldn't be uncommon for majority of our users to fall user 5+ user groups.
Part of this would involve us expanding the default length of the User Group ID from 10 to 40 (as per Best Practice for naming conventions) since 10 characters don't give us enough room to adequately name each group as we would like (again, based on Best Practice Naming Conventions).
We have found that the main information seems to be obtained from the UserGroupInfo table, but that table isn't present under the Data Dictionary (it's under the System Documentation, so unavailable to be changed that way by my understanding). We've also found the UserGroupName EDT, but that is already set at 40 characters. The form itself doesn't seem to restricting the length of the field either. We've discussed changing the field on the SQL directly, but again my understanding is that if we do a full synchronization it would overwrite this change.
Where can we go to change this particular setting, or is it possible to change?
The size of the user group id is defined as as system extended data type (here \System Documentation\Types\userGroupId) and you cannot change any of the properties including the size 10 length.
You should live with that, don't try to fake the system using direct SQL changes. Even if you did that, AX would still believe that length is 10.
You could change the SysUserInfo form to show the group name only. The groupId might as well be assigned by a number sequence in your context.
I wrote a job to change the string size via X++ and it works for EDTs, but it can't seem to find the "userGroupId". From the general feel of AX I get, I'd be willing to guess that they just have it in a different location, but maybe not. I wonder if this could be tweaked to work:
static void Job9(Args _args)
{
#AOT
TreeNode treeNode;
Struct propertiesExt;
Map mapNewPropertyValues;
void setTreeNodePropertyExt(
Struct _propertiesExt,
Map _newProperties
)
{
Counter propertiesCount;
Array propertyInfoArray;
Struct propertyInfo;
str propertyValue;
int i;
;
_newProperties.insert('IsDefault', '0');
propertiesCount = _propertiesExt.value('Entries');
propertyInfoArray = _propertiesExt.value('PropertyInfo');
for (i = 1; i <= propertiesCount; i++)
{
propertyInfo = propertyInfoArray.value(i);
if (_newProperties.exists(propertyInfo.value('Name')))
{
propertyValue = _newProperties.lookup(propertyInfo.value('Name'));
propertyInfo.value('Value', propertyValue);
}
}
}
;
treeNode = TreeNode::findNode(#ExtendedDataTypesPath);
// This doesn't seem to be able to find the system type
//treeNode = treeNode.AOTfindChild('userGroupId');
treeNode = treeNode.AOTfindChild('AccountCategory');
propertiesExt = treeNode.AOTgetPropertiesExt();
mapNewPropertyValues = new Map(Types::String, Types::String);
mapNewPropertyValues.insert('StringSize', '30');
setTreeNodePropertyExt(propertiesExt, mapNewPropertyValues);
treeNode.AOTsetPropertiesExt(propertiesExt);
treeNode.AOTsave();
info("Done");
}

Coding Standards for 3 tier architecture

i need some suggestion for working on 3 tier architecture, recently i completed one of my clients site, with 3 tier architecture, in that i was transforming the data directly in html from sql server 2008 and fetching the records in .net, .net was just doing the rendering task, so one of my friend said, it could reduce the performance drastically, but i never got any complaint from client regarding the same, as the records i am transforming in html from sql server 2008, is not more than max 10, and now for the second site, i want to take more precaution while rendering data on the site, now this time i have planned to again use 3 tier, but now instead of transforming data to html in sql server i am pulling the records from sql server 2008, to my datalogic layer, and in bussinesslogic layer, i am transforming it to HTML.. so can anyone suggest which is the best way to go about, the previous tranforming in HTML in SQL SERVER or in .NET
By Transforming in HTML i mean:
ALTER PROCEDURE [dbo].[SP_TVT_Article_Get]
#ID INT
AS
BEGIN
DECLARE #HTML NVARCHAR(MAX)
SET #HTML = '';
SELECT #HTML = '
<div style="margin-top:10px;" class="craig"><span style='+(SELECT CASE ISNULL(Author, '') WHEN '' THEN '"display:none; float:left"' ELSE '"display:block; float:left"' END)+'> ' + ISNULL(C.Author, '' )+ ' /</span> ' + DATENAME(DW, C.PublishDate) + ' ' + CONVERT(VARCHAR(15), CAST(C.PublishDate AS TIME), 100) +'</div>
<div class="sony_title">'+C.Title+'</div>' +
CASE
WHEN C.SecondaryTitle IS NOT NULL THEN
'<div class="tokiyo">' + C.SecondaryTitle + '</div>
'ELSE
'<div class="tokiyo">TOKYO: Six broadcasters & theaters in at least 22 will carry 3D coverage.</div>'
END +
'<div class="imgtxt_para01"> <img src="'+isnull(C.Thumbnail,'')+'" style="'+(SELECT CASE ISNULL(C.Thumbnail,'') WHEN '' THEN '"display:none"' ELSE '"display:block"' END)+'" />
'+ CAST(C.Article AS NVARCHAR(MAX)) +'</div>'
FROM CrossArticle_Article C
WHERE Id = #ID
SELECT #HTML
END
and this time which i am planning to do is like this..
My DataLogic Layer, will look like this:
public void GetArticle(int PortalID, int ArticleID, out DateTime PublishDate, out string Article, out string Author, out string Title)
{
object _getArticle = "";
Article = Author = Title = null;
PublishDate = DateTime.Now;
using (SqlCommand comGetArticle = new SqlCommand("sp_EQEM_GetArticle", ConnectDatabase))
{
comGetArticle.CommandType = CommandType.StoredProcedure;
comGetArticle.Parameters.AddRange(new SqlParameter[]{new SqlParameter("#PortalID", PortalID),
new SqlParameter("#ArticleID", ArticleID)});
ConnectDatabase.Open();
using (SqlDataReader reader = comGetArticle.ExecuteReader())
{
while (reader.Read())
{
Title = reader.GetValue(0).ToString();
Author = reader.GetValue(1).ToString();
PublishDate = Convert.ToDateTime(reader.GetValue(2));
Article = reader.GetValue(3).ToString();
}
}
ConnectDatabase.Close();
}
}
and bussinesslogic layer will look like this:
public object GetArticle()
{
string Title, Author, Article;
DateTime PublishDate;
connection.GetArticle(PortalID, ArticleID, out PublishDate, out Article, out Author, out Title);
StringBuilder str = new StringBuilder();
str.Append("<div class='aricle_para'>");
str.Append("<h1>" + Title + "</h1>");
str.Append("<span style='float:left; display:" + (String.IsNullOrEmpty(Author) ? "none" : "block") + "'>By " + Author + " | </span><span> " + PublishDate.DayOfWeek.ToString().Substring(0, 3) + ", " + PublishDate.ToString("dd MMM yyyy") + "</span><br />");
str.Append(HttpContext.Current.Server.HtmlDecode(Article));
str.Append("</div>");
return str.ToString();
}
and then i will be calling the bussinesslayer function GetArticle to the page, where i want to render article...
OMG, please don't do this. It's wrong in every way, because I see embedded HTML everywhere.
3-tier architecture means that persistence should not know about services should not know about views. There's nothing layered about this arrangement.
You exclude every UI developer ever when you do this. You'll need a back end developer for simple UI changes.
I see no leveraging of CSS or JavaScript.
How do you want to include a mobile UI?
This could not be more wrong.
A "tier" in an n-tier architecture is so called because it is functionally distinct from other parts of the application; in fact, it's more correct to say it's isolated from even the question of whether it's used in one or n applications.
"Layers" commonly refer to distinct groups of functionality within one tier.
"3-tier" applications came about because the pattern of using Data Access, Business Logic and Presentation in three distinct tiers is a quick fit for many scenarios, but it's by no means prescriptive that you need 3 tiers. The point is primarily that you have tiers at all.
In order to qualify as a tier, broadly speaking its responsibilities must not bleed in to another. By having a stored procedure in your database that returns HTML, you are bleeding presentation markup up into your business logic tier (of your chosen 3-tier approach) and then further outwards into your presentation logic.
You will find everything far simpler to test, and make performant, by returning only data from your stored procedures. Your business logic can process this data, choosing what (if any) filters, modifications and workflows to apply, and add metadata to that data before passing it outwards to your presentation tier that is solely responsible for placing that data inside of your HTML markup. In this way, your presentation tier is kept distinct, and you may then add layers to it that can generate markup for mobile applications, or JSON for RESTful services responses, etc. - all without the stored procedures caring.
Your friend's comments about performance optimisations were the tip of the iceberg, but may have referred to a natural consequence of keeping this separation: you would not be concatenating strings in your stored procedure to generate markup that is then further modified in your business logic.

Resources