Commit 0bafdf4c by Tuomas Riihimäki

Added beans projec library dependencies .classpath file.

1 parent 074aa366
......@@ -2,7 +2,7 @@ bortal realmin lisääminen glassfishiin.
1. Lisää code/LanBortalAuthModule.jar tiedosto hakemistoon glassfish/glassfish/lib/
2. lisää tiedostoon glassfish/glassfish/domains/domain1/config/login.conf tiedostoon:
2. lisää tiedostoon glassfish/glassfish/domains/login.conf tiedostoon:
bortalRealm {
fi.insomnia.bortal.BortalLoginModule required;
......@@ -11,3 +11,6 @@ bortalRealm {
3. suorita seuraava komento hakemistossa glassfish/glassfish/bin/
./asadmin create-auth-realm --classname fi.insomnia.bortal.BortalRealm --property jaas-context=bortalRealm omniarealm
./asadmin create-jdbc-connection-pool --datasourceclassname org.postgresql.ds.PGSimpleDataSource --restype javax.sql.DataSource --ping true --property DatabaseName=BortalDb:Password=derkoppa:User=bortal Omniapossu
\ No newline at end of file
......@@ -12,5 +12,6 @@
<attribute name="owner.project.facets" value="jst.java"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libs/PDFjet.jar"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
package fi.insomnia.bortal.utilities;
public class BillUtils {
private static final int[] multipliers = new int[] { 7, 3, 1 };
/**
* Calculates and return the reference number calculated from the given base
* @param base
* @return
*/
public static Integer createReferenceNumber(Integer base) {
return base * 10 + calculateChecksum(base);
}
/**
* This function will calculate the checksum for the bills checksum
* nuber for the given checksum base
* @param base Thebase of the checksum
* @return checksum integer in the range of 0-9 calculated from the given base
*/
public static Integer calculateChecksum(Integer base)
{
int checksum = 0;
for (int i = 0; base > 0; i = (i >= multipliers.length ? 0 : i + 1)) {
int num = base % 10;
checksum += multipliers[i] * num;
base = base / 10;
}
return (checksum % 10 == 0 ? 0 : 10 - (checksum % 10));
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!