I want to put RDF/XML format directly in SDB - jena

In Jena, I saved RDF/XML documents in SDB using the "read()" method and even created a file with RDF/XML documents in SDB using the "write" method.
What I want to try is to save Triple directly in SDB.
Here is my code
prefix = "http://example.org/terms/";
ns = "ex";
model.setNsPrefix(ns, prefix);
prefix3 = "http://www.w3.org/1999/02/22-rdf-syntax-ns";
ns3 = "rdf";
model.setNsPrefix(ns3, prefix3);
prefix6 = "http://www.test/2022/#";
ns6 = "base";
model.setNsPrefix(ns6, prefix6);
for(i = 0; i<index; i++) {
Resource s_A = model.createResource(A[i].o);
Property p_A = model.createProperty(prefix3);
Resource s_B = model.createResource(B[i].s);
Property p_B = model.createProperty(B[i].p);
Resource s_C = model.createResource(C[i].s);
Property p_C = model.createProperty(C[i].p);
//model.add(s_A, p_A, prefix6); //wish <ex:Description rdf:about=baseURI+"ID">
model.add(s_A, p_B, B[i].o); //wish <ex:Description.type>1</ex:Description.type>
model.add(s_A, p_C, C[i].o); //wish <ex:Description.open>0</ex:Description.open>
//wish </ex:Description>
}
I know this(model.add(s_A, p_A, prefix6);) part is wrong, but I don't know which method I use to wish. I don't know what else to do here.

Related

Springdoc-openapi external json file with relative path for example request body

I am looking for a way to use a relative path for external JSON files while defining the example request body.
My current definition is like this:
#Operation(requestBody = #RequestBody(description = "Request", content = #Content(schema = #Schema(implementation = Request.class), examples = {
#ExampleObject(
name = "An example request",
value = "{\n" +
"\"token\":\"token\"\n" +
"}",
summary = "Request"
)}
)),summary = "summ", description = "desc")
I want to keep JSON value on an external JSON file.
I know that "externalValue" field can be used instead of "value" to reference an external json file, but it requires a URL. I want to keep it in the project file and use the relative path. I am using Open API v3.
For those who are just looking for external JSON file usage, you can use external JSON file from a URL like this:
#Operation(requestBody = #RequestBody(description = "Request", content = #Content(schema = #Schema(implementation = Request.class), examples = {
#ExampleObject(
name = "An example request",
externalValue = "http://domain/test/example.json",
summary = "Request"
)}
)),summary = "summ", description = "desc")

How do you load all images at a time in pygame?

I'm trying to load all these images at once. Their all in the same directory so is there a way to load them all at once without being this repetitive?
bg = pygame.image.load('Desktop/Files/Dungeon Minigame/background.png')
f_zombie = pygame.image.load('Desktop/Files/Dungeon Minigame/f_zombie.png')
f_knight = pygame.image.load('Desktop/Files/Dungeon Minigame/f_knight.png')
b_knight = pygame.image.load('Desktop/Files/Dungeon Minigame/b_knight.png')
r_knight = pygame.image.load('Desktop/Files/Dungeon Minigame/r_knight.png')
heart = pygame.image.load('Desktop/Files/Dungeon Minigame/heart.png')
empty_heart = pygame.image.load('Desktop/Files/Dungeon Minigame/empty_heart.png')
Get a list of all the files in the directory (see os) and create a dictionary with the loaded files:
import os
path = 'Desktop/Files/Dungeon Minigame/'
filenames = [f for f in os.listdir(path) if f.endswith('.png')]
images = {}
for name in filenames:
imagename = os.path.splitext(name)[0]
images[imagename] = pygame.image.load(os.path.join(path, name)).convert_alpha()
You can access the images in the dictionary by its name:
screen.blit(images['background'], (0, 0))
Alternatively you can add variables to global namespace, using globals():
path = 'Desktop/Files/Dungeon Minigame/'
filenames = [f for f in os.listdir(path) if f.endswith('.png')]
for name in filenames:
imagename = os.path.splitext(name)[0]
globals()[imagename] = pygame.image.load(os.path.join(path, name)).convert_alpha()
screen.blit(background, (0, 0))

Update sequence number mismatch; requested USN = 2, database USN = 3

I am using Filenet 4.5.1 I have a module in my project where we move the contents from a folder to a newly created folder , and then delete them from old folder.
ObjectStore objectStore;
ReferentialContainmentRelationship toRcr = null;
ReferentialContainmentRelationship fromRcr = null;
DocumentSet documentSet;
Iterator documentIterator;
documentSet = fromFolder.get_ContainedDocuments();
documentIterator = documentSet.iterator();
Document document;
while(documentIterator.hasNext())
{
document = (Document) documentIterator.next();
toRcr = toFolder.file(document,AutoUniqueName.AUTO_UNIQUE, document.getClassName(),DefineSecurityParentage.DO_NOT_DEFINE_SECURITY_PARENTAGE);
toRcr.save(RefreshMode.REFRESH);
toFolder.save(RefreshMode.REFRESH);
fromRcr = fromFolder.unfile(document);
fromFolder.save(RefreshMode.REFRESH);
}
But, here toFolder.save(RefreshMode.REFRESH); is not being executed properly and an exception is coming
Exception in FNServices.getOldFileFolderObject() : The object {ADF64C74-F80D-4BD7-8A58-86699C66BFAC} has been modified since it was retrieved. Update sequence number mismatch; requested USN = 2, database USN = 3.
Here , the object refers to the new folder created.
Judging from IBM documentation, I believe you should create your folder first, and then worry about the filing after.
ObjectStore objectStore;
ReferentialContainmentRelationship toRcr = null;
ReferentialContainmentRelationship fromRcr = null;
DocumentSet documentSet;
Iterator documentIterator;
documentSet = fromFolder.get_ContainedDocuments();
documentIterator = documentSet.iterator();
Document document;
toFolder.save(RefreshMode.REFRESH);
fromFolder.save(RefreshMode.REFRESH);
while(documentIterator.hasNext())
{
document = (Document) documentIterator.next();
toRcr = toFolder.file(document,AutoUniqueName.AUTO_UNIQUE, document.getClassName(),DefineSecurityParentage.DO_NOT_DEFINE_SECURITY_PARENTAGE);
toRcr.save(RefreshMode.REFRESH);
fromRcr = fromFolder.unfile(document);
fromRcr.save(RefreshMode.REFRESH);
}
Take a look here: Working with Containment

How can one to dynamically parse a CSV file using C# and the Smart Format Detector in FileHelpers 3.1?

As per in this FileHelpers 3.1 example, you can automatically detect a CSV file format using the FileHelpers.Detection.SmartFormatDetector class.
But the example goes no further. How do you use this information to dynamically parse a CSV file? It must have something to do with the DelimitedFileEngine but I cannot see how.
Update:
I figured out a possible way but had to resort to using reflection (which does not feel right). Is there another/better way? Maybe using System.Dynamic? Anyway, here is the code I have so far, it ain't pretty but it works:
// follows on from smart detector example
FileHelpers.Detection.RecordFormatInfo lDetectedFormat = formats[0];
Type lDetectedClass = lDetectedFormat.ClassBuilderAsDelimited.CreateRecordClass();
List<FieldInfo> lFieldInfoList = new List<FieldInfo>(lDetectedFormat.ClassBuilderAsDelimited.FieldCount);
foreach (FileHelpers.Dynamic.DelimitedFieldBuilder lField in lDetectedFormat.ClassBuilderAsDelimited.Fields)
lFieldInfoList.Add(lDetectedClass.GetField(lField.FieldName));
FileHelperAsyncEngine lFileEngine = new FileHelperAsyncEngine(lDetectedClass);
int lRecNo = 0;
lFileEngine.BeginReadFile(cReadingsFile);
try
{
while (true)
{
object lRec = lFileEngine.ReadNext();
if (lRec == null)
break;
Trace.WriteLine("Record " + lRecNo);
lFieldInfoList.ForEach(f => Trace.WriteLine(" " + f.Name + " = " + f.GetValue(lRec)));
lRecNo++;
}
}
finally
{
lFileEngine.Close();
}
As I use the SmartFormatDetector to determine the exact format of the incoming Delimited files you can use following appoach:
private DelimitedClassBuilder GetFormat(string file)
{
var detector = new FileHelpers.Detection.SmartFormatDetector();
var format = detector.DetectFileFormat(file);
return format.First().ClassBuilderAsDelimited;
}
private List<T> ConvertFile2Objects<T>(string file, out DelimitedFileEngine engine)
{
var format = GetSeperator(file); // Get Here your FormatInfo
engine = new DelimitedFileEngine(typeof(T)); //define your DelimitdFileEngine
//set some Properties of the engine with what you need
engine.ErrorMode = ErrorMode.SaveAndContinue; //optional
engine.Options.Delimiter = format.Delimiter;
engine.Options.IgnoreFirstLines = format.IgnoreFirstLines;
engine.Options.IgnoreLastLines = format.IgnoreLastLines;
//process
var ret = engine.ReadFileAsList(file);
this.errorCount = engine.ErrorManager.ErrorCount;
var err = engine.ErrorManager.Errors;
engine.ErrorManager.SaveErrors("errors.out");
//return records do here what you need
return ret.Cast<T>().ToList();
}
This is an approach I use in a project, where I only know that I have to process Delimited files of multiple types.
Attention:
I noticed that with the files I recieved the SmartFormatDetector has a problem with tab delimiter. Maybe this should be considered.
Disclaimer: This code is not perfected but in a usable state. Modification and/or refactoring is adviced.

OpenOffice Draw macro to find replace text

I'm looking to find replace text within multiple PDF documents using Draw. Thus far I've managed to open the PDF however
mydoc.createReplaceDescription
appears not to be a valid property / method on a Draw doc. Although oddly this is used in many examples for writer and calc.
Are there any alternatives?
Okay after some playing around with the recorder in the Writer I managed to record a macro that seems to be more general purpose than the createReplaceDiscription I was trying earlier.
It's got a lot of bumf that I guess could be cleaned up but it works...
REM ***** BASIC *****
Sub Main
End Sub
sub WriterFindReplace
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(18) as new com.sun.star.beans.PropertyValue
args1(0).Name = "SearchItem.StyleFamily"
args1(0).Value = 2
args1(1).Name = "SearchItem.CellType"
args1(1).Value = 0
args1(2).Name = "SearchItem.RowDirection"
args1(2).Value = true
args1(3).Name = "SearchItem.AllTables"
args1(3).Value = false
args1(4).Name = "SearchItem.Backward"
args1(4).Value = false
args1(5).Name = "SearchItem.Pattern"
args1(5).Value = false
args1(6).Name = "SearchItem.Content"
args1(6).Value = false
args1(7).Name = "SearchItem.AsianOptions"
args1(7).Value = false
args1(8).Name = "SearchItem.AlgorithmType"
args1(8).Value = 0
args1(9).Name = "SearchItem.SearchFlags"
args1(9).Value = 65536
args1(10).Name = "SearchItem.SearchString"
args1(10).Value = "<<THE WORD YOUR FINDING>>"
args1(11).Name = "SearchItem.ReplaceString"
args1(11).Value = "<< THE WORD YOUR USING TO REPLACE>>"
args1(12).Name = "SearchItem.Locale"
args1(12).Value = 255
args1(13).Name = "SearchItem.ChangedChars"
args1(13).Value = 2
args1(14).Name = "SearchItem.DeletedChars"
args1(14).Value = 2
args1(15).Name = "SearchItem.InsertedChars"
args1(15).Value = 2
args1(16).Name = "SearchItem.TransliterateFlags"
args1(16).Value = 1280
args1(17).Name = "SearchItem.Command"
args1(17).Value = 3
args1(18).Name = "Quiet"
args1(18).Value = true
dispatcher.executeDispatch(document, ".uno:ExecuteSearch", "", 0, args1())
end sub

Resources