I am not sure how to add entries into the Calendar properly. I want to populate base on input from the data base.
I have tried the following but am unsure how to set the dates and entries. I am getting the data and placing into an ObserverableList . In my case the database table is CalendarData
public class CalendarController<CalendarEvent> extends Application {
private RosterService rosterService = new RosterServiceImpl();
private ObservableList<CalendarData> calendarList = FXCollections.observableArrayList();
public ObservableList<CalendarData> getCalendarDataList() {
if (!calendarList.isEmpty())
calendarList.clear();
calendarList = FXCollections.observableList((List<CalendarData>) rosterService.listCalendarData());
return calendarList;
}
#Override
public void start(Stage primaryStage) throws Exception {
CalendarView calendarView = new CalendarView();
Calendar shifts = new Calendar("ShiftRoster");
shifts.setStyle(Style.STYLE1);
CalendarSource myCalendarSource = new CalendarSource("My Calendars");
// myCalendarSource.getCalendars().addAll(shifts, holidays);
calendarView.getCalendarSources().addAll(myCalendarSource);
calendarView.setRequestedTime(LocalTime.now());
getCalendarDataList();
for(CalendarData task : calendarList){
Entry<String> entry = new Entry<String>(task.getShiftType());
LocalDate date = task.getShiftDate();
shifts.addEntries(dates);
}
CalendarSource calendarSourceTasks = new CalendarSource("Shifts");
calendarSourceTasks.getCalendars().addAll(shifts);
calendarView.getCalendarSources().setAll(calendarSourceTasks);
Solved it by doing the following code:
CalendarView calendarView = new CalendarView();
Calendar shifts = new Calendar("ShiftRoster");
shifts.setStyle(Style.STYLE1);
ZoneId id = ZoneId.of("Australia/Brisbane");
getCalendarDataList();
for (CalendarData task : calendarList) {
Entry<String> dentistAppointment = new Entry<>(task.getEmployeename());
String startTime = task.getStartTIme();
String endTime = task.getEndTime();
LocalDate date = task.getShiftDate();
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("H:mm:ss");
LocalTime start = LocalTime.parse(startTime, dtf);
LocalTime end = LocalTime.parse(endTime, dtf);
if (!start.isAfter(end)) {
dentistAppointment.setInterval(date);
dentistAppointment.setInterval(start, end);
shifts.addEntry(dentistAppointment);
}
if (!end.isAfter(start)) {
dentistAppointment.setInterval(date);
dentistAppointment.setInterval(date,start, date.plusDays(1),end);
shifts.addEntry(dentistAppointment);
}
}
CalendarSource calendarSourceTasks = new CalendarSource("Shifts");
calendarSourceTasks.getCalendars().addAll(shifts);
calendarView.getCalendarSources().setAll(calendarSourceTasks);
Related
ive got some code that works very well with picocli:
#Command(name = "parse", sortOptions = false, description = "parse input files and write to database")
class CommandLineArgumentParser {
#Option(names = { "-h", "--help" }, usageHelp = true, description = "display this message")
private boolean helpRequested = false;
#Option(names = { "-s", "--startDate"}, description = "First day at which to parse data",
converter = GermanDateConverter.class, paramLabel = "dd.MM.yyyy")
public LocalDate start;
#Option(names = { "-e", "--endDate"}, description = "Last day (inclusive) at which to stop parsing",
converter = GermanDateConverter.class, paramLabel = "dd.MM.yyyy")
public LocalDate end;
private static class GermanDateConverter implements ITypeConverter<LocalDate> {
#Override
public LocalDate convert(String value) throws Exception {
LocalDate result = null;
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy");
result = LocalDate.parse(value, formatter);
if (result.getYear() < 1900) {
throw new IllegalArgumentException("year should be after 1900");
}
return result;
}
}
#SpringBootApplication
public class Application implements CommandLineRunner {
public void run(String... args) throws Exception {
CommandLineArgumentParser commandlineparser = new CommandLineArgumentParser();
CommandLine commandLine = new CommandLine(commandlineparser);
try {
commandLine.parseArgs(args);
} catch (MissingParameterException e) {
System.out.println(e);
System.out.println();
CommandLine.usage(CommandLineArgumentParser.class, System.out);
System.exit(1);
} catch (ParameterException e) {
System.out.println(e);
System.out.println();
CommandLine.usage(CommandLineArgumentParser.class, System.out);
System.exit(1);
}
if (commandLine.isUsageHelpRequested()) {
commandLine.usage(System.out);
return;
} else if (commandLine.isVersionHelpRequested()) {
commandLine.printVersionHelp(System.out);
return;
}
if (commandlineparser.start == null) {
log.warn("no start date specified, using: 01.01.2005");
commandlineparser.start = LocalDate.of(2005, 01, 01);
}
if (commandlineparser.end == null) {
LocalDate timePoint = LocalDate.now();
log.warn("no end date specified, using today: " + timePoint.toString());
commandlineparser.end = timePoint;
}
}
but i did not find a simple example that shows multiple commands used, for example this one:
https://github.com/remkop/picocli/blob/master/src/test/java/picocli/Demo.java
does not compile:
int exitCode = new CommandLine(new Demo()).execute(args);
The method execute(CommandLine, List<Object>) in the type CommandLine is not applicable for the arguments (String[])
could somebody please post a example on howto use multiple commands?
I suspect you’re using an older version of the library. The execute(String []) : int method was introduced in picocli 4.0.
Upgrading and using the execute method instead of the parseArgs method will allow you to remove a lot of boilerplate code from the application: handling requests for usage/version help and dealing with invalid input is done automatically with the execute method.
Your commands should implement Runnable or Callable, and this is where the business logic of each command lives.
Modifying your example and giving it a subcommand:
#Command(name = "parse", sortOptions = false,
mixinStandardHelpOptions = true, version = “1.0”,
description = "parse input files and write to database",
subcommands = MySubcommand.class)
class CommandLineArgumentParser implements Callable<Integer> {
#Option(names = { "-s", "--startDate"}, description = "First day at which to parse data",
converter = GermanDateConverter.class, paramLabel = "dd.MM.yyyy")
public LocalDate start;
#Option(names = { "-e", "--endDate"}, description = "Last day (inclusive) at which to stop parsing",
converter = GermanDateConverter.class, paramLabel = "dd.MM.yyyy")
public LocalDate end;
private static class GermanDateConverter implements ITypeConverter<LocalDate> {
#Override
public LocalDate convert(String value) throws Exception {
LocalDate result = null;
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy");
result = LocalDate.parse(value, formatter);
if (result.getYear() < 1900) {
throw new IllegalArgumentException("year should be after 1900");
}
return result;
}
}
#Override
public Integer call() {
if (start == null) {
log.warn("no start date specified, using: 01.01.2005");
start = LocalDate.of(2005, 01, 01);
}
if (end == null) {
LocalDate timePoint = LocalDate.now();
log.warn("no end date specified, using today: " + timePoint.toString());
end = timePoint;
}
// more business logic here ...
// add finally return an exit code
int exitCode = ok ? 0 : 1;
return exitCode;
}
}
#Command(name = "foo")
class MySubcommand implements Callable<Integer> {
#Override
public Integer call() {
System.out.println("hi");
return 0;
}
}
#SpringBootApplication
public class Application implements CommandLineRunner {
public void run(String... args) throws Exception {
int exitCode = new CommandLine(
CommandLineArgumentParser.class,
new picocli.spring.PicocliSpringFactory())
.execute(args);
System.exit(exitCode);
}
}
Note that when using Spring in combination with picocli subcommands, you need to call the CommandLine constructor with a picocli.spring.PicocliSpringFactory.
For a more complete Spring example, see the picocli-spring-boot-starter README.
I am trying to implement a feature where you choose a date and time and the notification pops up on your phone. so after writing some code its still not working but everything seems fine
Activity code
FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
#RequiresApi(api = Build.VERSION_CODES.M)
#Override
public void onClick(View view) {
Calendar customCalendar = GregorianCalendar.getInstance();
DatePicker dp = findViewById(R.id.date_picker);
TimePicker picker = findViewById(R.id.time_picker);
customCalendar.set(
dp.getYear(), dp.getMonth(), dp.getDayOfMonth(), picker.getHour(), picker.getMinute(), 0);
long customTime = customCalendar.getTimeInMillis();
SimpleDateFormat sdf = new SimpleDateFormat(getString(R.string.notification_schedule_pattern), Locale.getDefault());
long currentTime = System.currentTimeMillis();
Log.d("time", "cistomTime " + customTime);
Log.d("time", "cistomTime " + currentTime);
if (customTime > currentTime) {
Data data = new Data.Builder().putInt(NOTIFICATION_ID, 0).build();
int delay = (int) (customTime - currentTime);
scheduleNotification(delay, data);
String titleNotificationSchedule = getString(R.string.notification_schedule_title);
Snackbar.make(
view,
titleNotificationSchedule + sdf
.format(customCalendar.getTime()),
LENGTH_LONG).show();
// Snackbar.make(coordinatorLayout, "Reminder set", LENGTH_LONG)
// .setAction("Action", null).show();
} else {
String errorNotificationSchedule = "Error occured";
Snackbar.make(coordinatorLayout, errorNotificationSchedule, LENGTH_LONG).show();
}
}
});
}
private void scheduleNotification(long delay, Data data) {
OneTimeWorkRequest notificationWork = new OneTimeWorkRequest.Builder(NotifyWork.class)
.setInitialDelay(delay, MILLISECONDS).setInputData(data).build();
WorkManager instanceWorkManager = WorkManager.getInstance(getApplicationContext());
instanceWorkManager.beginUniqueWork(NOTIFICATION_WORK, REPLACE, notificationWork).enqueue();
}
Worker class
public class NotifyWork extends Worker {
public static final String NOTIFICATION_ID = "notification_id";
public static final String NOTIFICATION_NAME = "Remember";
public static final String NOTIFICATION_CHANNEL = "Reminder_Channel";
public static final String NOTIFICATION_WORK = "Notification_Work";
public NotifyWork(#NonNull Context context, #NonNull WorkerParameters workerParams) {
super(context, workerParams);
}
#NonNull
#Override
public Result doWork() {
int id = getInputData().getInt(NOTIFICATION_ID, 0);
sendNotification(id);
return Result.success();
}
private void sendNotification(int id) {
NotificationManager notificationManager = (NotificationManager) getApplicationContext()
.getSystemService(Context.NOTIFICATION_SERVICE);
Bitmap bitmap = BitmapFactory.decodeResource(getApplicationContext().getResources(), R.drawable.ic_done_white_24dp);
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.putExtra(NOTIFICATION_ID, id);
String titleNotification = "Reminder";
String subtitleNotification = "Time To WakeUp";
PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder notification = new NotificationCompat.Builder(getApplicationContext(), NOTIFICATION_CHANNEL)
.setLargeIcon(bitmap).setContentTitle(titleNotification)
.setContentText(subtitleNotification).setDefaults(IMPORTANCE_DEFAULT).setSound(getDefaultUri(TYPE_NOTIFICATION))
.setContentIntent(pendingIntent).setAutoCancel(true);
notification.setPriority(IMPORTANCE_MAX);
notificationManager.notify(id, notification.build());
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
Uri ringtoneManager = getDefaultUri(TYPE_NOTIFICATION);
AudioAttributes audioAttributes = new AudioAttributes.Builder().setUsage(USAGE_NOTIFICATION_RINGTONE)
.setContentType(CONTENT_TYPE_SONIFICATION).build();
NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL, NOTIFICATION_NAME, NotificationManager.IMPORTANCE_DEFAULT);
channel.enableLights(true);
channel.setLightColor(RED);
channel.enableVibration(true);
channel.setSound(ringtoneManager, audioAttributes);
notificationManager.createNotificationChannel(channel);
}
}
I have a DatePicker and TimePicker, when you select date and time and click on the FAB button, you get notified at that particular time
somehow changing .setLargeIcon to .setSmallIcon and referencing the image directly without converting to bitmap eg .setSmallIcon(R.drawable.ic_done_white_24dp) solved the issue
I'm try to convert DemoEntity to DemoDto. And they have child attribute Collection<SubEntity> and Collection<SubDto>. Error happened when converting Collection<SubEntity>. If I don't add #JMap("subEntities"), JMapper would works well. Now I want that when converting DemoEntity, the Collection<SubEntity> could be converted together.
public class DemoEntity {
/** The id. */
private int id;
/** The code. */
private String code;
/** The date. */
private Date date;
private Collection<SubEntity> subEntities;
#JMapConversion(from = "date", to = "date")
public String convertDate(Date date) {
return date.toString();
}
public DemoEntity(int id, String code, Date date, Collection<SubEntity> subEntities) {
super();
this.id = id;
this.code = code;
this.date = date;
this.subEntities = subEntities;
}
...setter and getter...
}
public class DemoDto {
/** The id. */
#JMap
private Long id;
/** The code. */
#JMap
private String code;
/** The date. */
#JMap
private String date;
#JMap("subEntities")
private Collection<SubDto> subDtos;
... setter and getter...
}
The main method is below:
Collection<SubEntity> subEntities = new ArrayList<>();
for (int i = 1; i < 100; i++) {
SubEntity subEntity = new SubEntity(i, "C" + i, new Date());
subEntities.add(subEntity);
}
DemoEntity demoEntity = new DemoEntity(1, "D" + 1, new Date(), subEntities);
JMapperAPI api = new JMapperAPI();
MappedClass mappedClass = new MappedClass(SubDto.class);
api.add(mappedClass);
JMapper<DemoDto, DemoEntity> mapper = new JMapper<>(DemoDto.class, DemoEntity.class, api);
DemoDto demoDto = mapper.getDestination(demoEntity);
System.out.println(demoDto);
An exception happened, when covert DemoEntity.subEntities to DemoDto.subDtos
Exception in thread "main" com.googlecode.jmapper.exceptions.JMapperException: java.lang.NullPointerException
at com.googlecode.jmapper.config.JmapperLog.ERROR(JmapperLog.java:46)
at com.googlecode.jmapper.JMapper.<init>(JMapper.java:445)
at com.googlecode.jmapper.JMapper.<init>(JMapper.java:411)
at com.googlecode.jmapper.JMapper.<init>(JMapper.java:385)
at com.jmapper.JmapperDemo.main(JmapperDemo.java:35)
Caused by: java.lang.NullPointerException
at com.googlecode.jmapper.operations.complex.AComplexOperation.newInstance(AComplexOperation.java:107)
at com.googlecode.jmapper.operations.complex.AComplexOperation.newInstance(AComplexOperation.java:98)
at com.googlecode.jmapper.operations.recursive.MappedCollectionOperation.sharedCode(MappedCollectionOperation.java:64)
at com.googlecode.jmapper.operations.complex.AComplexOperation.sourceControl(AComplexOperation.java:156)
at com.googlecode.jmapper.operations.complex.AComplexOperation.genericFlow(AComplexOperation.java:133)
at com.googlecode.jmapper.operations.complex.AComplexOperation.write(AComplexOperation.java:89)
at com.googlecode.jmapper.generation.MapperConstructor.mapping(MapperConstructor.java:154)
at com.googlecode.jmapper.generation.MapperConstructor.wrappedMapping(MapperConstructor.java:123)
at com.googlecode.jmapper.generation.MapperConstructor.getMappings(MapperConstructor.java:89)
at com.googlecode.jmapper.generation.MapperGenerator.generateMapperClass(MapperGenerator.java:54)
at com.googlecode.jmapper.generation.MapperBuilder.generate(MapperBuilder.java:88)
at com.googlecode.jmapper.JMapper.createMapper(JMapper.java:458)
at com.googlecode.jmapper.JMapper.<init>(JMapper.java:440)
... 3 more
Besides, is there any method convert Collection<Entity> to Collection<Dto>
This is a case of recursive mapping, you need to map sub classes.
As you map DemoDTO with DemoEntity, you need to map SubDTO with SubEntity.
I am having some trouble figuring out the right way to go about creating a dynamic query that I can use values from DropDownList controls to filter and sort/order the results of a database query to fill a ListView. I am able to hard code individual queries, which works ok, except for the fact that it takes an incredible amount of effort, and is not easily changed.
My code is as follows (using all filters):
queryResult = From product In myEntities.InventoryProducts
Where product.VendorID = ddlFilterVendor.SelectedValue And product.ItemType = ddlItemType.SelectedValue And product.LabelSize = ddlLabelSize.SelectedValue And product.PrintLabel = boolPrint And product.Edited = boolEdited
Order By product.ID Ascending
Select product
Return queryResult
Is there a better method to this? I would like to be able to select the value from each DropDownList and generate a custom WHERE clause, as well as an ORDER BY clause.
Any help would be greatly appreciated, thanks.
I can give you a simple example as to how to to proceed with your idea. I am sure if you look through StackOverflow or search via google you will get code that does a better job of dynamic expression building. The same concept can be used for order by.
void Main()
{
var ops = new List<Ops>
{
new Ops
{
OperandType = typeof(string),
OpType=OpType.Equals,
OperandName = "Name",
ValueToCompare = "MM" // in your case this will be the values from the dropdowns
},
new Ops
{
OperandType = typeof(int),
OpType=OpType.Equals,
OperandName = "ID",
ValueToCompare = 1
},
};
var testClasses = new List<TestClass>
{
new TestClass { ID =1, Name = "MM", Date = new DateTime(2014,12,1)},
new TestClass { ID =2, Name = "BB", Date = new DateTime(2014,12,2)}
};
// this will produce prop => ((prop.Name == "MM") And (prop.ID == 1))
var whereDelegate = ExpressionBuilder.BuildExpressions<TestClass>(ops);
foreach(var item in testClasses.Where(whereDelegate))
{
Console.WriteLine("ID " +item.ID);
Console.WriteLine("Name " +item.Name);
Console.WriteLine("Date" + item.Date);
}
}
// Define other methods and classes here
public enum OpType
{
Equals
}
public class Ops
{
public Type OperandType {get; set;}
public OpType OpType {get; set;}
public string OperandName {get;set;}
public object ValueToCompare {get;set;}
}
public class TestClass
{
public int ID {get;set;}
public string Name {get; set;}
public DateTime Date {get;set;}
}
public class ExpressionBuilder
{
public static Func<T,bool> BuildExpressions<T>( List<Ops> opList)
{
Expression currentExpression= null;
var parameterExpression = Expression.Parameter(typeof(T), "prop");
for(int i =0; i< opList.Count; i++)
{
var op = opList[i];
Expression innerExpression = null;
switch(op.OpType)
{
case OpType.Equals :
{
var propertyExpression = Expression.Property(parameterExpression ,
op.OperandName);
var constExpression = Expression.Constant(op.ValueToCompare);
innerExpression = Expression.Equal(propertyExpression,
constExpression);
break;
}
}
if (i >0)
{
currentExpression = Expression.And(currentExpression, innerExpression);
}
else
{
currentExpression = innerExpression;
}
}
var lambdaExpression = Expression.Lambda<Func<T,bool>>(currentExpression,
new []{parameterExpression });
Console.WriteLine(lambdaExpression);
return lambdaExpression.Compile() ;
}
}
In my application, I am generating a datagrid programatically and binding it with a list. I am able to see the data in the datagrid but when I edit the cell, the underlying item in the list does not get updated. Here is the code
Window dateChangeWindow = new Window();
dateChangeWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
dateChangeWindow.Owner = Application.Current.MainWindow;
dateChangeWindow.SizeToContent = SizeToContent.WidthAndHeight;
dateChangeWindow.Title = "Date Change";
StackPanel stackPanel = new StackPanel();
stackPanel.Orientation = Orientation.Vertical;
DataGrid requestGrid = new DataGrid();
requestGrid.CanUserResizeColumns = false;
requestGrid.CanUserResizeRows = false;
requestGrid.CanUserReorderColumns = false;
requestGrid.CanUserSortColumns = true;
requestGrid.AutoGenerateColumns = false;
DataGridTextColumn requestIdColumn = new DataGridTextColumn();
requestIdColumn.Header = "Request Id";
Binding idBinding = new Binding("RequestId");
idBinding.Mode = BindingMode.OneWay;
requestIdColumn.Binding = idBinding;
requestGrid.Columns.Add(requestIdColumn);
DataGridTemplateColumn startDateColumn = new DataGridTemplateColumn();
startDateColumn.Header = "Start Date";
Binding startDateBinding = new Binding("StartDate");
startDateBinding.Mode = BindingMode.TwoWay;
FrameworkElementFactory startDateFactory = new FrameworkElementFactory(typeof(DatePicker));
startDateFactory.SetBinding(DatePicker.SelectedDateProperty, startDateBinding);
DataTemplate startDateTemplate = new DataTemplate();
startDateTemplate.VisualTree = startDateFactory;
startDateColumn.CellTemplate = startDateTemplate;
startDateColumn.CellEditingTemplate = startDateTemplate;
requestGrid.Columns.Add(startDateColumn);
DataGridTemplateColumn endDateColumn = new DataGridTemplateColumn();
endDateColumn.Header = "End Date";
Binding endDateBinding = new Binding("EndDate");
endDateBinding.Mode = BindingMode.TwoWay;
FrameworkElementFactory endDateFactory = new FrameworkElementFactory(typeof(DatePicker));
endDateFactory.SetBinding(DatePicker.SelectedDateProperty, endDateBinding);
DataTemplate endDateTemplate = new DataTemplate();
endDateTemplate.VisualTree = endDateFactory;
endDateColumn.CellTemplate = endDateTemplate;
endDateColumn.CellEditingTemplate = endDateTemplate;
requestGrid.Columns.Add(endDateColumn);
requestGrid.ItemsSource = requestList;
requestGrid.Margin = new Thickness(0, 10, 0, 0);
requestGrid.HorizontalAlignment = HorizontalAlignment.Center;
stackPanel.Children.Add(requestGrid);
Button changeDoneBtn = new Button();
changeDoneBtn.Content = "Submit";
changeDoneBtn.Click += new RoutedEventHandler(changeDone_Click);
changeDoneBtn.Margin = new Thickness(0, 20, 0, 10);
changeDoneBtn.HorizontalAlignment = HorizontalAlignment.Center;
stackPanel.Children.Add(changeDoneBtn);
dateChangeWindow.Content = stackPanel;
dateChangeWindow.ShowDialog();
The ItemsSource requestList is populated before the window creation. It is declared as
IList<DateChangeWrapper> requestList = new List<DateChangeWrapper>();
And the DateChangeWrapper class looks like this
public class DateChangeWrapper : INotifyPropertyChanged
{
public DateChangeWrapper(ResponseWrapper responseWrapper)
{
RequestId = responseWrapper.RequestId;
ParentRequestId = responseWrapper.ParentRequestId;
StartDate = responseWrapper.StartDate;
EndDate = responseWrapper.EndDate;
}
private DateTime startDate;
private DateTime endDate;
public int RequestId { get; private set; }
public int ParentRequestId { get; private set; }
public DateTime StartDate
{
get { return startDate; }
set
{
startDate = value;
OnPropertyChanged("StartDate");
}
}
public DateTime EndDate
{
get { return endDate; }
set
{
endDate = value;
OnPropertyChanged("EndDate");
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
var e = new PropertyChangedEventArgs(propertyName);
handler(this, e);
}
}
}
As you can see from the code, I have two columns StartDate and EndDate which are displayed as DatePickers . When I debug the code, the point where window.ShowDialog is called, I see the get accessor of the Dates getting called. But when I change the value in the datepicker, the setter does not get called and my list still has the old value.
Please help me
The problem was that the changed value was not getting updated back to the underlying source because of UpdateSourceTrigger. By default, this has the value of LostFocus. I changed it to PropertyChanged and it worked ! :)
I added the following line of code to my binding
startDateBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
and similarly for EndDate