-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DB 5.1__DEV11: unit support for time #3099
Changes from 2 commits
82be762
9d689f1
98e7353
d586e43
636f63b
e100a7a
ecf8ee4
414553d
9d97e6c
150866a
bd3310b
a9ac5ba
4f5a942
b12217b
1b57c31
0f482ff
e424ed6
a9f2e17
90f896e
27799c5
73e708a
fbd305b
8d06dbd
d747f7e
e0891b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (C) 2014 University of Dundee & Open Microscopy Environment. | ||
* All rights reserved. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
|
||
#ifndef CLASS_TIME | ||
#define CLASS_TIME | ||
|
||
module omero { | ||
|
||
module model { | ||
|
||
/** | ||
**/ | ||
["protected"] class Time | ||
{ | ||
|
||
/** | ||
**/ | ||
double value; | ||
|
||
string unit; | ||
|
||
/** | ||
**/ | ||
double getValue(); | ||
|
||
/** | ||
**/ | ||
void setValue(double time); | ||
|
||
/** | ||
**/ | ||
string getUnit(); | ||
|
||
/** | ||
**/ | ||
void setUnit(string unit); | ||
|
||
Time copy(); | ||
|
||
}; | ||
}; | ||
}; | ||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (C) 2014 University of Dundee & Open Microscopy Environment. | ||
* All rights reserved. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
|
||
package omero.model; | ||
|
||
/** | ||
* Blitz wrapper around the {@link ome.model.util.Time} class. | ||
* | ||
* @author Josh Moore, josh at glencoesoftware.com | ||
*/ | ||
public class TimeI extends Time { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
public final static Ice.ObjectFactory Factory = new Ice.ObjectFactory() { | ||
|
||
public Ice.Object create(String arg0) { | ||
return new TimeI(); | ||
} | ||
|
||
public void destroy() { | ||
// no-op | ||
} | ||
|
||
}; | ||
|
||
public double getValue(Ice.Current current) { | ||
return this.value; | ||
} | ||
|
||
public void setValue(double time, Ice.Current current) { | ||
this.value = time; | ||
} | ||
|
||
public String getUnit(Ice.Current current) { | ||
return this.unit; | ||
} | ||
|
||
public void setUnit(String unit, Ice.Current current) { | ||
this.unit = unit; | ||
} | ||
|
||
public Time copy(Ice.Current ignore) { | ||
TimeI copy = new TimeI(); | ||
copy.setValue(getValue()); | ||
copy.setUnit(getUnit()); | ||
return copy; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright (C) 2014 University of Dundee & Open Microscopy Environment. | ||
* All rights reserved. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
package ome.model.units; | ||
|
||
import java.io.Serializable; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Embeddable; | ||
|
||
/** | ||
* class storing both a time duration (double) and a unit for that duration | ||
* (e.g. ns, ms, s, etc.) | ||
*/ | ||
@Embeddable | ||
public class Time implements Serializable { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
// ~ Constructors | ||
// ========================================================================= | ||
|
||
public Time() { | ||
} | ||
|
||
// ~ Fields | ||
// ========================================================================= | ||
|
||
/** | ||
* float representation of the time, i.e. duration, represented by this | ||
* field. | ||
*/ | ||
private double value; | ||
|
||
/** | ||
* string representation of the units which should be considering when | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. considered |
||
* producing a representation of the {@link #time} field. | ||
*/ | ||
private String unit; | ||
|
||
// ~ Property accessors : used primarily by Hibernate | ||
// ========================================================================= | ||
|
||
@Column(name = "value", nullable = false) | ||
public double getValue() { | ||
return this.value; | ||
} | ||
|
||
@Column(name = "unit", nullable = false) | ||
public String getUnit() { | ||
return this.unit; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if a |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1669,6 +1669,7 @@ | |
id int8 not null, | ||
deltaT float8, | ||
permissions int8 not null, | ||
exposureTimeUnit varchar(255), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 255 seems a bit wasteful; can't we use a much smaller size here given that most unit symbols and/or names will be very small? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another possibility on the db side would be to have a foreign key reference to a time units table to make it restricted to the model enum values. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Possibly, but that's something we should do across the board in another PR, since we don't have any support for that at the moment. More interesting to me would be whether or not this should actually be an enum. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For any code to be able to robustly cope with units, I consider an enum as a necessity. This does constrain which units are possible to use of course, but the set Andrew has created covers all the SI system and then some, so I think the number of cases where this won't be sufficient is approaching zero. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, this was mostly just to have an example of touching all the necessary pieces. Just chatted through the current
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: what I'd really like would be to have:
but we don't currently have support for that in Hibernate and the DB. It might be worth it though. |
||
exposureTime float8, | ||
positionX float8, | ||
positionY float8, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will probably need some comments (-: