I'm currently working with the OPC UA Foundation Java Stack, without any additional SDK's.
I am unable to implement subscriptions with monitored items and to get the change notifications via the publish response. I am new to Java, any help regarding this would be really helpful. Thank you.
This is C#, not Java but you should be able to translate it. I hope it helps.
if (this.subscription == null)
{
this.subscription = new Opc.Ua.Client.Subscription(this.session.DefaultSubscription)
{
PublishingInterval = this.config.ReportingInterval,
TimestampsToReturn = TimestampsToReturn.Both
};
this.session.AddSubscription(subscription);
subscription.Create();
}
item = new MonitoredItem(subscription.DefaultItem)
{
StartNodeId = new NodeId(property.Identifier, this.config.NamespaceId),
SamplingInterval = this.config.SamplingInterval,
QueueSize = this.config.QueueSize,
};
subscription.AddItem(item);
subscription.ApplyChanges()
Related
I'm working on a project that used Uber Cadence Java Client. How can I get the list of open/closed workflows from the code? I can get it from CLI but not from java code.
Thank you.
WorkflowServiceTChannel cadenceService =
new WorkflowServiceTChannel(ClientOptions.defaultInstance());
ListOpenWorkflowExecutionsRequest request = new ListOpenWorkflowExecutionsRequest();
request.setDomain(DOMAIN);
=request.set...;
ListOpenWorkflowExecutionsResponse resp = cadenceService.ListOpenWorkflowExecutions(request);
ListClosedWorkflowExecutionsRequest request = new ListClosedWorkflowExecutionsRequest();
request.setDomain(DOMAIN);
=request.set...;
ListClosedWorkflowExecutionsResponse resp = cadenceService.ListClosedWorkflowExecutions(request);
// If you have advanced visibility
ListWorkflowExecutionsRequest request = new ListWorkflowExecutionsRequest();
request.setDomain(DOMAIN);
=request.setQuery(...);
ListWorkflowExecutionsResponse resp = cadenceService.ListWorkflowExecutions(request);
See how the cadenceService is used in this sample
Documentation about advanced visibility
Mac OS has a setting that allows users to define when scroll bars should be visible (automatically, when scrolling, always).
Is there a way to find out the current setting using Java?
For me, running on macOS 10.14.6, the setting (when not set to "automatic") can be found in the current user's global preferences ~/Library/Preferences/.GlobalPreferences.plist. This file has content such as:
{
AKDeviceUnlockState = :false;
AKLastIDMSEnvironment = 0;
AppleActionOnDoubleClick = "Maximize";
AppleAntiAliasingThreshold = 4;
AppleInterfaceStyle = "Dark";
AppleLanguages = ( "en-US" );
AppleLanguagesDidMigrate = "10.14.6";
AppleLocale = "en_US";
AppleMiniaturizeOnDoubleClick = :false;
AppleShowScrollBars = "Always";
...
}
I'm not 100% sure if this covers all possible scenarios, but you could start by parsing this file, finding the AppleShowScrollBars value and using that to drive your desired functionality.
There's a handy library called dd-plist that allows you to use the following code:
try {
final File preferences = new File("~/Library/Preferences/.GlobalPreferences.plist");
final NSDictionary root = (NSDictionary) PropertyListParser.parse(preferences);
final String scrollbars = root.get("AppleShowScrollBars").toString();
System.out.println(scrollbars);
} catch (Exception e) {
// Handle errors
System.out.println();
}
I look at the docs regarding this and struggling about with how IDriveItemCollectionPage works.
I am currently doing the following, trying to list all children DriveItems of the root drive of a site given its Drive Id with the Java SDK
public ArrayList<DriveItem> getDriveItemChildrenFoldersOfRootDrive(String rootDriveId){
//gets the children folder driveI
IDriveItemCollectionPage driveChildren= mGraphServiceClient.drives().byId(rootDriveId).root().children().buildRequest().get();
ArrayList<DriveItem> results = new ArrayList<DriveItem>();
results.addAll(driveChildren.getCurrentPage());
return results;
}
I realize if getNextPage returns null then there are no more results, but do you have to make another api call to get the next page if there is one?How do I do that with the above setup?
Agree with Brad. I tested at my side and got a success. Here is my code
public static void main(String[] args) {
IGraphServiceClient client = GetClient();
IDriveCollectionPage page = client.drives().buildRequest().get();
List<Drive> drives = page.getCurrentPage();
while(page.getNextPage() != null){
page = page.getNextPage().buildRequest().get();
drives.addAll(page.getCurrentPage());
}
System.out.println(drives.size());
}
I am working on a android news app which gets news from google news rss feed. I am currently getting news and showing it to the user in my app. But I want to show notification to the user when new news appears on google rss. I have no idea how to do it as I am new to android and could not find anything relevant on google. Thank you.
Here is my code I have done so far
internal static List<FeedItem> GetFeedItems(string url)
{
List<FeedItem> feedItemsList = new List<FeedItem>();
try
{
HttpClient wc = new HttpClient();
var html = wc.GetStringAsync(new Uri(url)).Result;
XElement xmlitems = XElement.Parse(html);
// We need to create a list of the elements
List<XElement> elements = xmlitems.Descendants("item").ToList();
// Now we're putting the informations that we got in our ListBox in the XAML code
// we have to use a foreach statment to be able to read all the elements
// Description , Link , Title are the attributes in the RSSItem class that I've already added
List<FeedItem> aux = new List<FeedItem>();
foreach (XElement rssItem in elements)
{
FeedItem rss = new FeedItem();
rss.Description = rssItem.Element("description").Value;
rss.Link = rssItem.Element("link").Value;
rss.Title = rssItem.Element("title").Value;
feedItemsList.Add(rss);
}
}
catch (Exception)
{
throw;
}
return feedItemsList;
}
Use parse's push notification,it's very easy to use and has great documents.
https://parse.com
go for push notification service. its the only way to get the notification .
follow this tutorial... http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/
Notification manager is what you want here.
see this http://developer.android.com/guide/topics/ui/notifiers/notifications.html ?
A simple google search also shows tutorials for the same
I am trying to import the vmdk to AWS EC2, but there seems to be no good java API documentation.
I have come across below flow, which should work,
DiskImageDetail id = new DiskImageDetail();
id.setFormat(DiskImageFormat.VMDK);
// id.setImportManifestUrl(importManifestUrl)
// TODO: set to 10GB e.g.
id.setBytes(80000000000L);
VolumeDetail volume = new VolumeDetail();
volume.setSize(80000000000L);
DiskImage i = new DiskImage();
i.setImage(id);
i.setVolume(volume);
i.setDescription("disk image");
List<DiskImage> listImages = new ArrayList<DiskImage>();
listImages.add(i);
ImportInstanceLaunchSpecification ls = new ImportInstanceLaunchSpecification();
ImportInstanceRequest ir = new ImportInstanceRequest();
ir.setDescription("Test");
ir.setDiskImages(listImages);
ir.setRequestCredentials(Connection.getAWSCredentials());
// ir.setGeneralProgressListener()
ir.setLaunchSpecification(ls);
// Some code to set
ImportVolumeRequest ivr = new ImportVolumeRequest();
//ivr.setSomeData();
AmazonEC2 ec2 = // set some connection
ec2.importInstance(ir);
ec2.importVolume(ivr);
But I am not sure about what values to pass, there's no sample code as well !
It can be done with the cmdlets but with Java I don't see anything hopeful.
Appreciate any help on this.
Thanks in advance