Apple CalDav does not return event overlapping with given date-time range - icloud

I have two events in the Apple iCLoud calendar: one begins at 20220326T040000Z, the other begins at 20220326T060000Z. Both last for 1 hour so the first one is 4am-5am, and the second one 6am-7am.
Now I use the following query to obtain the events overlapping with period 4:30am - 6:30am (both events should be overlapping):
<c:calendar-query
xmlns:c="urn:ietf:params:xml:ns:caldav"
xmlns:d="DAV:">
<d:prop>
<c:calendar-data />
</d:prop>
<c:filter>
<c:comp-filter name="VCALENDAR">
<c:comp-filter name="VEVENT">
<c:time-range start="20220326T043000Z" end="20220326T063000Z" />
</c:comp-filter>
</c:comp-filter>
</c:filter>
</c:calendar-query>
But the https://p62-caldav.icloud.com server returns only the second event:
SUMMARY:test title 2
DTSTART:20220326T060000Z
DURATION:PT60M
If I change the query to the period 4:00am - 6:30am:
<c:calendar-query
xmlns:c="urn:ietf:params:xml:ns:caldav"
xmlns:d="DAV:">
<d:prop>
<c:calendar-data />
</d:prop>
<c:filter>
<c:comp-filter name="VCALENDAR">
<c:comp-filter name="VEVENT">
<c:time-range start="20220326T040000Z" end="20220326T063000Z" />
</c:comp-filter>
</c:comp-filter>
</c:filter>
</c:calendar-query>
I'm getting both events:
SUMMARY:test title 0
DTSTART:20220326T040000Z
DURATION:PT60M
SUMMARY:test title 2
DTSTART:20220326T060000Z
DURATION:PT60M
It seems the Apple server does not return event 4am-5am if the requested range is 4:30am-6:30am. Or is there something wrong with my queries?

Related

MAUI Bound Entry does not refresh even though the underlying value changes

I am really quite confused now, and I am sure that this is something quite simple.
On the "Expense" screen I have this simplified entry:
<Entry
x:Name="entryCountOfReceipts"
Text="{Binding Expense.CountOfReceipts, Mode=OneWay}"
IsReadOnly="true"
TextChanged="EntryCountOfReceipts_TextChanged">
</Entry>
The goal is to show that this expense has N receipts attached.
Why do I have an Entry instead of a label ? Because I want to be able to trigger in the "Expense" page a comparison between the original Expense object and the current one in order to enable or disable the save button.
This comparison is done like this:
In my xaml.cs I have this code:
private void EntryCountOfReceipts_TextChanged(object sender, TextChangedEventArgs e)
{
if (!ScreenIsStillLoading)
{
viewModel.ChangesWereMade = Utils.Utils.ChangesWereMade(viewModel.Expense, er_ExpenseOriginal);
}
}
and my Save button has these dataTriggers:
<DataTrigger TargetType="Button" Binding="{Binding ChangesWereMade}" Value="false">
<Setter Property="IsEnabled" Value="false" />
<Setter Property="BackgroundColor" Value="Gray" />
</DataTrigger>
<DataTrigger TargetType="Button" Binding="{Binding ChangesWereMade}" Value="true">
<Setter Property="IsEnabled" Value="true" />
<Setter Property="BackgroundColor" Value="Black" />
</DataTrigger>
Okay. I load the screen with an expense already having in the SQLite database two receipts attached.
My entry correctly shows 2.
In the viewModel the expense is set up correctly:
[ObservableProperty]
private Expense expense;
My model looks like this (simplified):
public class Expense
{
public double Amount { get; set; }
[PrimaryKey, AutoIncrement]
public int? ID { get; set; }
[Ignore]
public int CountOfReceipts { get; set; }
[OneToMany(CascadeOperations = CascadeOperation.All)]
public List<Receipt> Receipts { get; set; }
}
Then I take a photo of my receipt, and if everything worked properly, I execute this:
Expense.Receipts.Add(receipt);
Expense.CountOfReceipts = Expense.Receipts.Count;
(Note: I know I could have bound my view directly to Expense.Receipts.Count, but bear with me).
So in Debug I see that the Expense.CountOfReceipts goes from 2 to 3. Correct.
My viewModel.ChangesWereMade gets set to true, and my Save button gets enabled. Great. But my entry does NOT get refreshed, and persists in showing 2 instead of 3.
Why is it not refreshing to the new bound value ?
What am I missing here ?
Thanks a lot.
Alex.
You could try raise property changed after add new receipt:
Expense.Receipts.Add(receipt);
Expense.CountOfReceipts = Expense.Receipts.Count;
OnPropertyChanged(nameof(Expense));
Note: you could check the text value in EntryCountOfReceipts_TextChanged handler
private void EntryCountOfReceipts_TextChanged(object sender, TextChangedEventArgs e)
{
var a = e.OldTextValue;
var b = e.NewTextValue; // please confirm if the newtextvalue is the value you want
}
Hope it works for you.

Mock a message from a 3rd party system in Mule using MUnit

I'm writing a test suite (using Munit) for a Mule application that is processing new data coming from an instance of Magento. One of my flows is polling Magento for new customers and the message it receives is of type: com.magento.api.CustomerCustomerEntity
I'm wondering how I'd mock this so that in my test case, when the Magento message processor is called I can return a payload of the same type and make the appropriate assertations?
Currently my Munit test looks as follows:
<mock:config name="mock_MagentoToSalesforce" doc:name="Mock configuration"/>
<spring:beans>
<spring:import resource="classpath:MagentoToSalesforce.xml"/>
<spring:bean id="myBean" name="myBean" class="com.magento.api.CustomerCustomerEntity">
<spring:property name="email" value="test#test.com"/>
</spring:bean>
</spring:beans>
<munit:test name="MagentoToSalesforce-test-getCustomersFlowTest" description="Test">
<mock:when config-ref="mock_MagentoToSalesforce" messageProcessor=".*:.*" doc:name="Mock">
<mock:with-attributes>
<mock:with-attribute whereValue-ref="#[string:Get New Customers]" name="doc:name"/>
</mock:with-attributes>
<mock:then-return payload-ref="#[app.registry.myBean]"/>
</mock:when>
<flow-ref name="getCustomers" doc:name="Flow-ref to getCustomers"/>
</munit:test>
And the flow I'm trying to test is:
<flow name="getCustomers" processingStrategy="synchronous">
<poll doc:name="Poll">
<fixed-frequency-scheduler frequency="30" timeUnit="SECONDS"/>
<watermark variable="watermark" default-expression="#[new org.mule.el.datetime.DateTime().plusYears(-30)]" update-expression="#[new org.mule.el.datetime.DateTime().plusYears(-0)]" selector-expression="#[new org.mule.el.datetime.DateTime(payload.created_at, 'yyyy-MM-dd HH:mm:ss')]"/>
<magento:list-customers config-ref="Magento" filter="dsql:SELECT confirmation,created_at,created_in,customer_id,dob,email,firstname,group_id,increment_id,lastname,middlename,password_hash,prefix,store_id,suffix,taxvat,updated_at,website_id FROM CustomerCustomerEntity WHERE updated_at > '#[flowVars.watermark]'" doc:name="Get New Customers"/>
</poll>
<foreach doc:name="For Each">
<data-mapper:transform config-ref="MagentoCustomer_To_SalesforceContact" doc:name="Map Customer to SFDC Contact">
<data-mapper:input-arguments>
<data-mapper:input-argument key="ContactSource">Magento</data-mapper:input-argument>
</data-mapper:input-arguments>
</data-mapper:transform>
<flow-ref name="upsertSalesforceContactFlow" doc:name="upsertSalesforceContactFlow"/>
</foreach>
</flow>
Update following Ryan's answer:
Changed the expression to return a payload of #[ent = new com.magento.api.CustomerCustomerEntity(); ent.setEmail('test#test.com'); return [ent];] - note, changed the method to setEmail to match the documentation here. The error I get with this is:
ERROR 2015-06-22 09:58:34,719 [main] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Object "org.mule.transport.NullPayload" not of correct type. It must be of type "{interface java.lang.Iterable,interface java.util.Iterator,interface org.mule.routing.MessageSequence,interface java.util.Collection}" (java.lang.IllegalArgumentException). Message payload is of type: NullPayload
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Object "org.mule.transport.NullPayload" not of correct type. It must be of type "{interface java.lang.Iterable,interface java.util.Iterator,interface org.mule.routing.MessageSequence,interface java.util.Collection}" (java.lang.IllegalArgumentException)
org.mule.util.collection.EventToMessageSequenceSplittingStrategy:64 (null)
2. Object "org.mule.transport.NullPayload" not of correct type. It must be of type "{interface java.lang.Iterable,interface java.util.Iterator,interface org.mule.routing.MessageSequence,interface java.util.Collection}" (java.lang.IllegalArgumentException). Message payload is of type: NullPayload (org.mule.api.MessagingException)
org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor:32 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.IllegalArgumentException: Object "org.mule.transport.NullPayload" not of correct type. It must be of type "{interface java.lang.Iterable,interface java.util.Iterator,interface org.mule.routing.MessageSequence,interface java.util.Collection}"
at org.mule.util.collection.EventToMessageSequenceSplittingStrategy.split(EventToMessageSequenceSplittingStrategy.java:64)
at org.mule.util.collection.EventToMessageSequenceSplittingStrategy.split(EventToMessageSequenceSplittingStrategy.java:25)
at org.mule.routing.CollectionSplitter.splitMessageIntoSequence(CollectionSplitter.java:29)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
One way is to build up the object yourself using the constructor or properties/setters.
From the docs:
http://mulesoft.github.io/magento-connector/2.1.2/java/com/magento/api/CustomerCustomerEntity.html
<mock:then-return payload-ref="#[ent = new com.magento.api.CustomerCustomerEntity(); ent.email('test#test.com'); return ent;]"/>
You can also create these objects aS reusable spring beans and reference them from MEL.
<bean class="com.magento.api.CustomerCustomerEntity" id="myEntityWithEmail">
<property name="email" value="test#test.com" />
</bean>
<mock:then-return payload-ref="#[app.registry.myEntityWithEmail]"/>
After your update I can see that you sre using a foreach which expects a collection or iterable. YOu can return a collection of you custom object simply in MEL using: [] for example:
#[ent = new com.magento.api.CustomerCustomerEntity(); ent.email('test#test.com'); return [ent];]
More on MEL here: https://developer.mulesoft.com/docs/display/current/Mule+Expression+Language+MEL
Or again you can use Spring to return a list:
<util:list id="entities">
<ref bean="myEntityWithEmail" />
</util:list>

Only first when expression works in apache camel choice?

I have this route which check if body begins with "01" or "02" and calls different beans based on that. the problem is that only first one works. for example if I send a message beginning with "01"
it works fine but if my message begins with "02" the otherwise part gets executed and i get the error message with an empty body.
<route id="genericService">
<from uri="servlet:///genericService"/>
<choice>
<when>
<simple>${body} regex "^01.*$"</simple>
<bean ref="cardFacade" method="getBalance" />
</when>
<when>
<simple>${body} regex "^02.*$"</simple>
<bean ref="depositFacade" method="getBalance" />
</when>
<otherwise>
<transform>
<simple>error: ${body}</simple>
</transform>
</otherwise>
</choice>
<marshal>
<json />
</marshal>
<transform>
<simple>${body}</simple>
</transform>
</route>
The problem is the servlet component provides the body as a stream that is only readable once. So you need to either enable stream caching, or convert the message body to a non stream type such as String or byte[].
You can find more details here
http://camel.apache.org/why-is-my-message-body-empty.html
And also see the 1st box on this page
http://camel.apache.org/servlet
I had the same problem in Java DSL (not the compilation issue). What I have to do is add .endchoice() for each and every choice some thing as below:
from(endPointTopic)
.errorHandler(deadLetterChannel)
.log("Message from Topic is ${body} & header string is ${header.Action}" )
.choice()
.when(header("Action").isEqualTo("POST"))
.setHeader(Exchange.HTTP_METHOD, constant("POST"))
.setHeader("Content-Type", constant("application/json"))
.convertBodyTo(String.class)
.to("log:like-to-see-all?level=INFO&showAll=true&multiline=true")
.to(privateApi)
.log("POST request for " + topicName)
.endChoice()
.when(header("Action").isEqualTo("PUT"))
.setHeader(Exchange.HTTP_METHOD, constant("PUT"))
.setHeader("Content-Type", constant("application/json"))
.convertBodyTo(String.class)
.to("log:like-to-see-all?level=INFO&showAll=true&multiline=true")
.to(privateApi)
.log("PUT request for " + topicName)
.endChoice()
.when(header("Action").isEqualTo("DELETE"))
.setHeader(Exchange.HTTP_METHOD, constant("DELETE"))
.setHeader("Content-Type", constant("application/json"))
.convertBodyTo(String.class)
.to("log:like-to-see-all?level=INFO&showAll=true&multiline=true")
.to(privateApi)
.log("DELET request for " + topicName)
.endChoice()
.otherwise()
.setHeader(Exchange.HTTP_METHOD, constant("GET"))
.setHeader("Content-Type", constant("application/json"))
.convertBodyTo(String.class)
.to("log:like-to-see-all?level=INFO&showAll=true&multiline=true")
.to(privateApi)
.log("Un-known HTTP action so posting to GET queue")
.endChoice();

Getting an empty list of services from a valid OWLS document

I'm struggling with an abandoned java library (with a down maven repository) to work with OWLS called owls-api. I'm trying to get the list of services from an OWLS document:
OWLKnowledgeBase kb = OWLFactory.createKB();
OWLIndividualList<Service> services = kb.readAllServices("http://127.0.0.1/services/1.1/BookPrice.owls");
System.out.println(services.toString());
I keep getting an empty services list, Why ?
<?xml version="1.0" encoding="WINDOWS-1252"?>
<rdf:RDF xmlns:owl = "http://www.w3.org/2002/07/owl#"
xmlns:rdfs = "http://www.w3.org/2000/01/rdf-schema#"
xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:service = "http://www.daml.org/services/owl-s/1.1/Service.owl#"
xmlns:process = "http://www.daml.org/services/owl-s/1.1/Process.owl#"
xmlns:profile = "http://www.daml.org/services/owl-s/1.1/Profile.owl#"
xmlns:grounding = "http://www.daml.org/services/owl-s/1.1/Grounding.owl#"
xml:base = "http://127.0.0.1/services/1.1/BookFinder.owls">
<owl:Ontology rdf:about="">
<owl:imports rdf:resource="http://127.0.0.1/ontology/Service.owl" />
<owl:imports rdf:resource="http://127.0.0.1/ontology/Process.owl" />
<owl:imports rdf:resource="http://127.0.0.1/ontology/Profile.owl" />
<owl:imports rdf:resource="http://127.0.0.1/ontology/Grounding.owl" />
<owl:imports rdf:resource="http://127.0.0.1/ontology/books.owl" />
</owl:Ontology>
<service:Service rdf:ID="TITLE_BOOK_SERVICE">
<service:presents rdf:resource="#TITLE_BOOK_PROFILE"/>
<service:describedBy rdf:resource="#TITLE_BOOK_PROCESS"/>
<service:supports rdf:resource="#TITLE_BOOK_GROUNDING"/>
</service:Service>
<profile:Profile rdf:ID="TITLE_BOOK_PROFILE">
<service:isPresentedBy rdf:resource="#TITLE_BOOK_SERVICE"/>
<profile:serviceName xml:lang="en">
BookFinder
</profile:serviceName>
<profile:textDescription xml:lang="en">
This service returns the information of a book whose title best matches the given string.
</profile:textDescription>
<profile:hasInput rdf:resource="#_TITLE"/>
<profile:hasOutput rdf:resource="#_BOOK"/>
<profile:has_process rdf:resource="TITLE_BOOK_PROCESS" /></profile:Profile>
<!--<process:ProcessModel rdf:ID="TITLE_BOOK_PROCESS_MODEL">
<service:describes rdf:resource="#TITLE_BOOK_SERVICE"/>
<process:hasProcess rdf:resource="#TITLE_BOOK_PROCESS"/>
</process:ProcessModel>-->
<process:AtomicProcess rdf:ID="TITLE_BOOK_PROCESS">
<service:describes rdf:resource="#TITLE_BOOK_SERVICE"/>
<process:hasInput rdf:resource="#_TITLE"/>
<process:hasOutput rdf:resource="#_BOOK"/>
</process:AtomicProcess>
<process:Input rdf:ID="_TITLE">
<process:parameterType rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI">http://127.0.0.1/ontology/books.owl#Title</process:parameterType>
</process:Input>
<process:Output rdf:ID="_BOOK">
<process:parameterType rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI">http://127.0.0.1/ontology/books.owl#Book</process:parameterType>
</process:Output >
<grounding:WsdlGrounding rdf:ID="TITLE_BOOK_GROUNDING">
<service:supportedBy rdf:resource="#TITLE_BOOK_SERVICE"/>
<grounding:hasAtomicProcessGrounding>
<grounding:WsdlAtomicProcessGrounding rdf:ID="TITLE_BOOK_AtomicProcessGrounding"/>
</grounding:hasAtomicProcessGrounding>
</grounding:WsdlGrounding>
<grounding:WsdlAtomicProcessGrounding rdf:about="#TITLE_BOOK_AtomicProcessGrounding">
<grounding:wsdlDocument rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI"
>http://127.0.0.1/wsdl/TitleBook.wsdl</grounding:wsdlDocument>
<grounding:owlsProcess rdf:resource="#TITLE_BOOK_PROCESS"/>
<grounding:wsdlOperation>
<grounding:WsdlOperationRef>
<grounding:operation rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI"
>http://127.0.0.1/wsdl/TitleBook#get_BOOK</grounding:operation>
<grounding:portType rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI"
>http://127.0.0.1/wsdl/TitleBook#TitleBookSoap</grounding:portType>
</grounding:WsdlOperationRef>
</grounding:wsdlOperation>
<grounding:wsdlInputMessage rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI"
>http://127.0.0.1/wsdl/TitleBook#get_BOOKRequest</grounding:wsdlInputMessage>
<grounding:wsdlOutputMessage rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI"
>http://127.0.0.1/wsdl/TitleBook#get_BOOKResponse</grounding:wsdlOutputMessage>
<grounding:wsdlInput>
<grounding:WsdlInputMessageMap>
<grounding:owlsParameter rdf:resource="#_TITLE"/>
<grounding:wsdlMessagePart rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI"
>http://127.0.0.1/wsdl/TitleBook#_TITLE</grounding:wsdlMessagePart>
<grounding:xsltTransformationString>None (XSL)</grounding:xsltTransformationString>
</grounding:WsdlInputMessageMap>
</grounding:wsdlInput>
<grounding:wsdlOutput>
<grounding:WsdlOutputMessageMap>
<grounding:owlsParameter rdf:resource="#_BOOK"/>
<grounding:wsdlMessagePart rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI"
>http://127.0.0.1/wsdl/TitleBook#_BOOK</grounding:wsdlMessagePart>
<grounding:xsltTransformationString>None (XSL)</grounding:xsltTransformationString>
</grounding:WsdlOutputMessageMap>
</grounding:wsdlOutput>
</grounding:WsdlAtomicProcessGrounding>
</rdf:RDF>
(* all static files are well server using grizzly java web server)
Is there any alternative to this buggy library to work with owls files ?
Update
https://github.com/tarrsalah/owls-example/issues/1
The RDF data here isn't all that complex, so it's not too hard to get what you're looking for by using a SPARQL query. E.g., you can use the following query to get the following results:
prefix service: <http://www.daml.org/services/owl-s/1.1/Service.owl#>
select ?service { ?service a service:Service }
----------------------------------------------------------------------
| service |
======================================================================
| <http://127.0.0.1/services/1.1/BookFinder.owls#TITLE_BOOK_SERVICE> |
----------------------------------------------------------------------
If you want to do this a bit more programmatically, it's just listing instances of the class
http://www.daml.org/services/owl-s/1.1/Service.owl#Service, so you could get that class as an OWLClass, and use getIndividuals to retrieve the set of its instances.

Elmah Filter for Nancy MVC Framework

I'm using Nancy MVC and Nancy.Elmah. Currently, there's a bug in Nancy that raises an exception for requests with accept headers of "*". Here's the Elmah log:
System.ArgumentException
inputString not in correct Type/SubType format Parameter name: *
System.ArgumentException: inputString not in correct Type/SubType format
Parameter name: *
at Nancy.Responses.Negotiation.MediaRange.FromString(String contentType)
at Nancy.Routing.DefaultRouteInvoker.<>c__DisplayClass5a.<>c__DisplayClass5c.<GetCompatibleHeaders>b__4f(MediaRange mr)
at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Nancy.Routing.DefaultRouteInvoker.GetCompatibleHeaders(IEnumerable`1 coercedAcceptHeaders, NancyContext context, Negotiator negotiator)
at Nancy.Routing.DefaultRouteInvoker.ProcessAsNegotiator(Object routeResult, NancyContext context)
at Nancy.Routing.DefaultRouteInvoker.InvokeRouteWithStrategy(Object result, NancyContext context)
at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
at CallSite.Target(Closure , CallSite , DefaultRouteInvoker , Object , NancyContext )
at Nancy.Routing.DefaultRouteInvoker.Invoke(Route route, DynamicDictionary parameters, NancyContext context)
at Nancy.Routing.DefaultRequestDispatcher.Dispatch(NancyContext context)
at Nancy.NancyEngine.InvokeRequestLifeCycle(NancyContext context, IPipelines pipelines)
I tried filtering it with the following web.config
<errorFilter>
<test>
<or>
<regex binding="Exception" pattern="inputString not in correct Type/SubType format Parameter name: \*" />
</or>
</test>
</errorFilter>
But the errors are not filtered out.
Also tried binding="BaseException.Message" without luck.
I would like a way to filter these messages from being logged. Could some "correct" my filter configuration above to do so? Thanks!
Well, after a few more hours of trail and error I discovered the issue is that the, "Parameter name: *" portion is not part of the actual exception message. I'm guessing that the message in the log is a concatenation of the exception message and parameter values. Changed the filter as shown and it's works.
<errorFilter>
<test>
<regex binding="Exception.Message" pattern="inputString not in correct Type/SubType format" />
</test>
</errorFilter>