DoNotForward Graph Api Event With Java - java

I have an application I am working on where a user will make an reservation for an office. Once the user makes it they are sent a calendar event via graph api so their Calendar reflects their reservation. I am trying to use the DoNotForward Boolean type to send in the singleValueExtendedProperties setting but nothing has worked.
Please Only answer using Java as the language. Thank you
**Note that I am sending the event and receiving it without any trouble until I try to add the DoNotForward. Below is a portion of the code that represents the Graph API Event.
Questions:
Has anyone configured an Event with the DoNoForward Option?
Can you provide me some guidance on what I am doing wrong?
Event event = new Event();
ItemBody eventBody = new ItemBody();
eventBody.contentType = BodyType.HTML;
eventBody.content = doc.html();
event.body = eventBody;
event.subject = "MyWorkSpot Reservation (" + environmentName + ") : " + buildingName + " Floor: " + floorName + " Seat: " + seatCode + " Time: " + reservationTime;
event.showAs = FreeBusyStatus.FREE;
event.isReminderOn = false;
event.reminderMinutesBeforeStart = 0;
event.isAllDay = true;
DateTimeTimeZone start = new DateTimeTimeZone();
start.dateTime = formattedResAllDayStartDate + "T00:00:00";
start.timeZone = "Eastern Standard Time";
event.start = start;
DateTimeTimeZone end = new DateTimeTimeZone();
end.dateTime = nextDay + "T00:00:00";
end.timeZone = "Eastern Standard Time";
event.end = end;
LinkedList<Attendee> attendeesList = new LinkedList<Attendee>();
Attendee attendees = new Attendee();
EmailAddress emailAddressEvent = new EmailAddress();
emailAddressEvent.address = recipientEmailAddress;
attendees.emailAddress = emailAddressEvent;
attendees.type = AttendeeType.REQUIRED;
attendeesList.add(attendees);
event.attendees = attendeesList;
SingleValueLegacyExtendedPropertyCollectionResponse singleValColRes = new SingleValueLegacyExtendedPropertyCollectionResponse();
SingleValueLegacyExtendedProperty singleValProp = new SingleValueLegacyExtendedProperty();
singleValProp.id = "Boolean {00020329-0000-0000-C000-000000000046} Name DoNotForward";
singleValProp.value = "true";
singleValProp.oDataType = "Boolean";
singleValColRes.value.add(0, singleValProp);
event.singleValueExtendedProperties = new SingleValueLegacyExtendedPropertyCollectionPage(singleValColRes, null);

Related

How to extract the best set of parameters from a TrainValidationSplitModel in Java?

I am using a ParamGridBuilder to construct a grid of parameters to search over and TrainValidationSplit to determine the best model (RandomForestClassifier), in Java. Now, I want to know what are the parameters (maxDepth, numTrees) from ParamGridBuilder that produces the best model.
Pipeline pipeline = new Pipeline().setStages(new PipelineStage[]{
new VectorAssembler()
.setInputCols(new String[]{"a", "b"}).setOutputCol("features"),
new RandomForestClassifier()
.setLabelCol("label")
.setFeaturesCol("features")});
ParamMap[] paramGrid = new ParamGridBuilder()
.addGrid(rf.maxDepth(), new int[]{10, 15})
.addGrid(rf.numTrees(), new int[]{5, 10})
.build();
BinaryClassificationEvaluator evaluator = new BinaryClassificationEvaluator().setLabelCol("label");
TrainValidationSplit trainValidationSplit = new TrainValidationSplit()
.setEstimator(pipeline)
.setEstimatorParamMaps(paramGrid)
.setEvaluator(evaluator)
.setTrainRatio(0.85);
TrainValidationSplitModel model = trainValidationSplit.fit(dataLog);
System.out.println("paramMap size: " + model.bestModel().paramMap().size());
System.out.println("defaultParamMap size: " + model.bestModel().defaultParamMap().size());
System.out.println("extractParamMap: " + model.bestModel().extractParamMap());
System.out.println("explainParams: " + model.bestModel().explainParams());
System.out.println("numTrees: " + model.bestModel().getParam("numTrees"))//NoSuchElementException: Param numTrees does not exist.
Those tries do not help...
paramMap size: 0
defaultParamMap size: 0
extractParamMap: {
}
explainParams:
I found a way:
Pipeline bestModelPipeline = (Pipeline) model.bestModel().parent();
RandomForestClassifier bestRf = (RandomForestClassifier) bestModelPipeline.getStages()[1];
System.out.println("maxDepth : " + bestRf.getMaxDepth());
System.out.println("numTrees : " + bestRf.getNumTrees());
System.out.println("maxBins : " + bestRf.getMaxBins());

Google Sheets API send multiple data in one requisition

How to send multiple data in just one request to the sheets API?
Example:
I am currently querying a database, and each row returned sends a request to update the data in the Google Sheet.
Here's the code:
// Consulta Desvios TL8
ResultSet DesviosTL8 = stm.executeQuery("QUERY_STRING");
int DiaDsvAnt = 0;
int celulaInicial = 10;
while (DesviosTL8.next()) {
int DiaDsv = DesviosTL8.getInt(2);
int valorDsv = DesviosTL8.getInt(1);
System.out.print("\n" + DiaDsv + " Dia Anterior: " + DiaDsvAnt + " Valor " + valorDsv);
celulaRealizado = "GRÁFICO PRODUÇÃO!L" + celulaInicial;
List<List<Object>> valor = new ArrayList<>();
List<Object> valorLista = new ArrayList<>();
valorLista.add(valorDsv);
valor.add(valorLista);
// Insiro na Planilha
ValueRange valorTurno1DiaAtual = new ValueRange().setValues(valor).setMajorDimension("ROWS");
serviço.spreadsheets().values().update(IdPlanilha, celulaRealizado, valorTurno1DiaAtual)
.setValueInputOption("RAW").execute();
// Somo +1
celulaInicial = celulaInicial + 1;
}
DiaDsvAnt = DiaDsv;
}
I would like instead of sending the request to each loop, that the request be sent only at the end of the results.
Example
Query returned 10 rows
Then it will send a request with all the data to fill the cells
GRÁFICO PRODUÇÃO!L10
Up to Cell
GRÁFICO PRODUÇÃO!L20

Updating database table is failing using update clause in hibernate

am trying to update a batch of columns in a table called customer . it works when i update two columns when hard coded the data.my aim is to fetch data from another table will updating the other. please here. it's not throwing any exception but just the code is not running . Thanks in advance
Session session = HibernateUtil.getSessionFactory().openSession();
customerdata.stream().forEach((row) -> {
session.beginTransaction();
// record data loggingg of customer import data transaction
String sql = "UPDATE Customer SET first_name = :first_name ,second_name = :second_name,"
+ "other_names = :other_name,gender = :gender,"
+ "date_opened = :date_opened,date_approved = :date_approved,branch_code = :branch_code,"
+ "national_id_number = :national_id_number,crb_number = :crb_number,"
+ "passport_number = :passport_number,passport_expiry_date = :passport_expiry_date,"
+ "voters_number = :voters_number,student_id_number = :student_id_number,"
+ "employer_id_number = :employer_id_number,finance_card_number = :finance_card_number,"
+ "driving_permit_number = :driving_permit_number,nssf_number = :nssf_number,tin_number = :tin_number,"
+ "police_id_number = :police_id_number,updf_number = :updf_number,"
+ "mobile = :mobile,telephone1 = :telephone1,telephone2 = :telephone2,"
+ "email = :email ,is_salaried = :is_salaried,plot_number = :plot_number,postal_address = :postal_address,"
+ "street = :street,account_operating_mode = :account_operating_mode,"
+ "primary_account_type = :primary_account_type,"
+ "address_type = :address_type,address_description = :address_description,dob_given = :dob_given,"
+ "date_of_birth = :date_of_birth, client_type = :client_type, country_of_origin = :country_of_origin,"
+ "city_of_origin = :city_of_origin,city_description = :city_description, employment_type = :employment_type,"
+ "introducer_details_available = :introducer_details_available,literacy_level = :literacy_level,"
+ "literacy_description = :literacy_description,marital_status = :marital_status,"
+ "marital_status_description = :marital_status_description,"
+ "nationality = :nationality,number_of_dependants = :number_of_dependants,residence = :residence,"
+ "residence_type = :residence_type ,resident_state = :resident_state,type_of_id = :type_of_id,"
+ "client_status = :client_status ,date_closed = :date_closed WHERE rim = :rim";
Query query = session.createQuery(sql);
query.setParameter("fname", row[2].toString());
query.setParameter("second_name", row[3].toString());
query.setParameter("other_name", row[4].toString());
query.setParameter("gender", row[5].toString());
query.setParameter("date_opened", (Date) row[6]);
query.setParameter("date_approved", (Date) row[7]);
query.setParameter("branch_code", row[8].toString());
query.setParameter("national_id_number", Integer.parseInt(row[9].toString()));
query.setParameter("crb_number", row[10].toString());
query.setParameter("passport_number", row[11].toString());
query.setParameter("passport_expiry_date", (Date) row[12]);
query.setParameter("voters_number", row[13].toString());
query.setParameter("student_id_number", row[14].toString());
query.setParameter("employer_id_number", row[15].toString());
query.setParameter("finance_card_number", row[16].toString());
query.setParameter("driving_permit_number", row[17].toString());
query.setParameter("nssf_number", row[18].toString());
query.setParameter("tin_number", row[19].toString());
query.setParameter("police_id_number", row[20].toString());
query.setParameter("updf_number", row[21].toString());
query.setParameter("mobile", row[22].toString());
query.setParameter("telephone1", row[23].toString());
query.setParameter("telephone2", row[24].toString());
query.setParameter("email", row[25].toString());
query.setParameter("is_salaried", (Boolean) row[26]);
query.setParameter("plot_number", row[27].toString());
query.setParameter("postal_address", Integer.parseInt(row[28].toString()));
query.setParameter("street", row[29].toString());
query.setParameter("account_operating_mode", Integer.parseInt(row[30].toString()));
query.setParameter("primary_account_type", Integer.parseInt(row[31].toString()));
query.setParameter("address_type", row[32].toString());
query.setParameter("address_description", row[33].toString());
query.setParameter("dob_given", (Boolean) row[34]);
query.setParameter("date_of_birth", (Date) row[35]);
query.setParameter("client_type", row[36].toString());
query.setParameter("country_of_origin", row[37].toString());
query.setParameter("city_of_origin", row[38].toString());
query.setParameter("city_description", row[39].toString());
query.setParameter("employment_type", row[40].toString());
query.setParameter("introducer_details_available", row[41].toString());
query.setParameter("literacy_level", row[42].toString());
query.setParameter("literacy_description", row[43].toString());
query.setParameter("marital_status", row[44].toString());
query.setParameter("marital_status_description", row[45].toString());
query.setParameter("nationality", row[46].toString());
query.setParameter("number_of_dependants", Integer.parseInt(row[47].toString()));
query.setParameter("residence", row[48].toString());
query.setParameter("residence_type", row[49].toString());
query.setParameter("resident_state", row[50].toString());
query.setParameter("type_of_id", Integer.parseInt(row[51].toString()));
query.setParameter("client_status", row[52].toString());
query.setParameter("date_closed", (Date) row[53]);
//setting rim data
query.setParameter("rim",row[1].toString());
query.executeUpdate();
session.getTransaction().commit();
System.err.println(xx++ + "RIM LOOPED:" + row[1].toString());
});
try {
session.close();
System.out.println("Update customer ends. . . . . . . . . . .");
} catch (NullPointerException nullPointer) {
System.out.println("updateing data log data property ::<updateEntireContent()>: Customer session object is closed.Exception handled. . .>>" + nullPointer);
}

Getting events from a specific calendar and specific date using Calendar Provider/Calendar.Contract

Ok so i am making an app which extracts the scynced calendars from the phone and displays them, i have read through many tutorials but i am still unsure how to do this.
I want to extract a calendar with the ACCOUNT_TYPE "ca.ryerson" (it is powered by google apps for education), then i wanna get all events from that particular database and only display them when someone clicks on the date provided.
So when someone clicks on Sept 5, it shows all the events on sept 5 from the ca.ryerson account, i am fairly new to android development and have almost 0 experience with database handling, i would really like your help with this one. I have read many tutorials and read through the documentation but i still cannot figure out how to do this.
Thanks :)
i was able to determine how to do this here is my code
ContentResolver contentResolver = getContentResolver();
final Cursor cursor = contentResolver.query(CalendarContract.Calendars.CONTENT_URI,
(new String[]{CalendarContract.Calendars._ID, CalendarContract.Calendars.CALENDAR_DISPLAY_NAME}), null, null, null);
while (cursor.moveToNext()) {
final String _id = cursor.getString(0);
final String displayName = cursor.getString(1);
int stringLength = displayName.length();
String output = displayName.substring(stringLength - 10);
//Log.d("Cursor", output);
if (output.equals("ryerson.ca")) {
//Log.d("Cursor", "true");
calendarID = new String[]{_id};
}
Uri.Builder builder = CalendarContract.Instances.CONTENT_URI.buildUpon();
Calendar beginTime = Calendar.getInstance();
beginTime.set(2014, Calendar.SEPTEMBER, 2, 8, 0);
long startMills = beginTime.getTimeInMillis();
Calendar endTime = Calendar.getInstance();
endTime.set(2014, Calendar.SEPTEMBER, 2, 20, 0);
long endMills = endTime.getTimeInMillis();
ContentUris.appendId(builder, startMills);
ContentUris.appendId(builder, endMills);
Cursor eventCursor = contentResolver.query(builder.build(), new String[]{CalendarContract.Instances.TITLE,
CalendarContract.Instances.BEGIN, CalendarContract.Instances.END, CalendarContract.Instances.DESCRIPTION},
CalendarContract.Instances.CALENDAR_ID + " = ?", calendarID, null);
while (eventCursor.moveToNext()) {
final String title = eventCursor.getString(0);
final Date begin = new Date(eventCursor.getLong(1));
final Date end = new Date(eventCursor.getLong(2));
final String description = eventCursor.getString(3);
Log.d("Cursor", "Title: " + title + "\tDescription: " + description + "\tBegin: " + begin + "\tEnd: " + end);
}

File diff against the last commit with JGit

I am trying to use JGit to get the differences of a file from the last commit to the most recent uncommitted changes. How can I do this with JGit? (using the command line would be the output of git diff HEAD)
Following several discussions (link1, link2) I come with a piece of code that is able to find the files that are uncommited, but it I cannot get the difference of the files
Repository db = new FileRepository("/path/to/git");
Git git = new Git(db);
AbstractTreeIterator oldTreeParser = this.prepareTreeParser(db, Constants.HEAD);
List<DiffEntry> diff = git.diff().setOldTree(oldTreeParser).call();
for (DiffEntry entry : diff) {
System.out.println("Entry: " + entry + ", from: " + entry.getOldId() + ", to: " + entry.getNewId());
DiffFormatter formatter = new DiffFormatter(System.out);
formatter.setRepository(db);
formatter.format(entry);
}
UPDATE
This issue was a long time ago. My existing for does display the uncommitted code. The current code that I am using for prepareTreeParser, in the context of displaying the difference, is:
public void gitDiff() throws Exception {
Repository db = new FileRepository("/path/to/git" + DEFAULT_GIT);
Git git = new Git(db);
ByteArrayOutputStream out = new ByteArrayOutputStream();
DiffFormatter formatter = new DiffFormatter( out );
formatter.setRepository(git.getRepository());
AbstractTreeIterator commitTreeIterator = prepareTreeParser(git.getRepository(), Constants.HEAD);
FileTreeIterator workTreeIterator = new FileTreeIterator( git.getRepository() );
List<DiffEntry> diffEntries = formatter.scan( commitTreeIterator, workTreeIterator );
for( DiffEntry entry : diffEntries ) {
System.out.println("DIFF Entry: " + entry + ", from: " + entry.getOldId() + ", to: " + entry.getNewId());
formatter.format(entry);
String diffText = out.toString("UTF-8");
System.out.println(diffText);
out.reset();
}
git.close();
db.close();
// This code is untested. It is slighting different for the code I am using in production,
// but it should be very easy to adapt it for your needs
}
private static AbstractTreeIterator prepareTreeParser(Repository repository, String ref) throws Exception {
Ref head = repository.getRef(ref);
RevWalk walk = new RevWalk(repository);
RevCommit commit = walk.parseCommit(head.getObjectId());
RevTree tree = walk.parseTree(commit.getTree().getId());
CanonicalTreeParser oldTreeParser = new CanonicalTreeParser();
ObjectReader oldReader = repository.newObjectReader();
try {
oldTreeParser.reset(oldReader, tree.getId());
} finally {
oldReader.release();
}
return oldTreeParser;
}
The following setup works for me:
DiffFormatter formatter = new DiffFormatter( System.out );
formatter.setRepository( git.getRepository() );
AbstractTreeIterator commitTreeIterator = prepareTreeParser( git.getRepository(), Constants.HEAD );
FileTreeIterator workTreeIterator = new FileTreeIterator( git.getRepository() );
List<DiffEntry> diffEntries = formatter.scan( commitTreeIterator, workTreeIterator );
for( DiffEntry entry : diffEntries ) {
System.out.println( "Entry: " + entry + ", from: " + entry.getOldId() + ", to: " + entry.getNewId() );
formatter.format( entry );
}
The uncommitted changes are made accessible trough the FileTreeIterator. Using formatter.scan() instead of the DiffCommand has the advantage that the formatter is set up properly to handle the FileTreeIterator. Otherwise you will get MissingObjectExceptions as the formatter tries to locate changes from the work tree in the repository.

Categories

Resources