diff --git a/.gitignore b/.gitignore index 330a090..102ebc9 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ /.project /out *.DS_Store +.ENV diff --git a/src/main/kotlin/au/gov/dxa/Controller.kt b/src/main/kotlin/au/gov/dxa/Controller.kt index 42695a5..c681b27 100644 --- a/src/main/kotlin/au/gov/dxa/Controller.kt +++ b/src/main/kotlin/au/gov/dxa/Controller.kt @@ -38,10 +38,7 @@ class Controller { @RequestMapping("/service/{id}/{title}") fun detailPage(@PathVariable id:String,@PathVariable title:String, model:MutableMap): String{ val serviceDescription = serviceDescriptionService.get(id) - return _detailPage(serviceDescription, title, id, model) - } - private fun _detailPage(serviceDescription:ServiceDTO?, title: String, id: String, model: MutableMap): String { if (serviceDescription == null) return "detail" var content:String = "" var pageTitle:String = title diff --git a/src/main/kotlin/au/gov/dxa/ServiceDescriptionRepository.kt b/src/main/kotlin/au/gov/dxa/ServiceDescriptionRepository.kt index 757ed17..a5b7538 100644 --- a/src/main/kotlin/au/gov/dxa/ServiceDescriptionRepository.kt +++ b/src/main/kotlin/au/gov/dxa/ServiceDescriptionRepository.kt @@ -2,7 +2,6 @@ package au.gov.dxa import com.beust.klaxon.* import org.springframework.stereotype.Component -import javax.servlet.http.HttpServletRequest import java.net.URL data class ServiceDTO(val name:String = "", val description:String = "", val pages:List = listOf("")) @@ -18,8 +17,7 @@ class ServiceDescriptionRepository(mock:MutableList? = null) { private fun getService(id:String) : ServiceDTO { var returnString: String = getRESTReturnString("service",id) - val serviceDTO = Klaxon().parse(returnString) ?: ServiceDTO() - return serviceDTO + return Klaxon().parse(returnString) ?: ServiceDTO() } private fun read(name:String):String{ @@ -29,30 +27,26 @@ class ServiceDescriptionRepository(mock:MutableList? = null) { return inputAsString } - fun get(id:String):ServiceDTO?{ return getService(id) } + data class IndexDTO(val content:List) + data class IndexServiceDTO(val id:String, val name:String, val description:String) fun list(): List{ - val list = mutableListOf() var returnString: String = getRESTReturnString() + val index = Klaxon().parse(returnString) - val splitdata = returnString.replace("[\"","").replace("\"]","").split("\",\"") - - for(serviceData in splitdata) - { - //temp code until structure is final - var serviceCuttent = getService(serviceData.split("/").last()) - list.add(ServiceListVM(serviceCuttent.name, serviceCuttent.description,"Metadata", "Published", serviceData.split("/").last())) - } - return list.toList() + return index!!.content.map { it -> ServiceListVM(it.name, it.description, "Metadata", "Published", it.id) } } private fun getRESTReturnString(endpoint : String = "index", endPointID:String = "") : String { var returnString: String = "" - val url = System.getenv("BaseRepoURI") + endpoint + if (endpoint.last() == '/') endPointID else "/$endPointID" + val baseRepoUri = System.getenv("BaseRepoURI")?: throw RuntimeException("No environment variable: BaseRepoURI") + + + val url = baseRepoUri + endpoint + if (endpoint.last() == '/') endPointID else "/$endPointID" try { val con = URL(url).openConnection() con.readTimeout = 1000 diff --git a/src/main/resources/samples/ato.accrole.0001.2017.list.01.00.xsd b/src/main/resources/samples/ato.accrole.0001.2017.list.01.00.xsd deleted file mode 100755 index 353308e..0000000 --- a/src/main/resources/samples/ato.accrole.0001.2017.list.01.00.xsd +++ /dev/null @@ -1,255 +0,0 @@ - - - - - - This schema was generated from a template. - Manual changes to this file will be overwritten if the schema is regenerated. - Generated on 2017-03-27T12:23:20, by ESR Version 1.57.0.0 using ESR Database - - - - - Information related to the sender - - - - - Information related to the entity - - - - - - - Information related to the sender - - - - - Identifiers.TaxAgentNumber.Identifier - - - - - - - - - - Australian Business Number - Alias: ACCROLE1 - Business Definition: A unique public identifier issued to all entities registered in the Australian Business Register (ABR), to be used in their dealings with government. Companies registered under the Corporations Law and business entities carrying on an enterprise in Australia are entitled to an ABN. - - - - - - - - - - - - Tax Agent Number - Alias: ACCROLE2 - Business Definition: An external identifier issued by the ATO on behalf of the Tax Agent's Board. It is used to uniquely identify an individual who has been registered by the Board as a Tax Agent. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Pagination - - - - - Record limit - Alias: ACCROLE10 - Report Guidance: This is the value that specifies the number of client account records to be returned per page from the service. - Business Definition: This is the maximum number of records to be returned in a list of values. - - - - - - - - - - - Record start number - Alias: ACCROLE11 - Report Guidance: The index of the first record to be returned. - Business Definition: This number represents the position of a record in a list of records. - - - - - - - - - - - - - Information related to the entity - - - - - Tax File Number - Alias: ACCROLE3 - Business Definition: A unique number issued by the Tax Office to individuals and organisations to identify their tax records. It increases the efficiency in administering tax and other Australian Government systems such as income support payments. It is also used as the identifier for clients' income tax roles. A Tax File Number (TFN) can be used externally only for communication with the Tax Office, either directly by the client, or by an external organisation that is required to collect and quote the client's TFN to the Tax Office. - - - - - - - - - - - - Australian Business Number - Alias: ACCROLE4 - Business Definition: A unique public identifier issued to all entities registered in the Australian Business Register (ABR), to be used in their dealings with government. Companies registered under the Corporations Law and business entities carrying on an enterprise in Australia are entitled to an ABN. - - - - - - - - - - - - Withholding Payer Number - Alias: ACCROLE59 - Business Definition: The Withholding Payer Number (WPN) is allocated to clients who have withholding obligations under Pay As You Go (PAYG) withholding but who do not have an Australian Business Number (ABN). Its primary purpose is for quotation on payment summaries issued to their employees. For example, private individuals not carrying on an enterprise employing a nanny or housekeeper, would be allocated a WPN. - Business Guidance: The Withholder Payer Number reported must belong to the payer named in this record. - - - - - - - - - - - - Australian Taxation Office Reference Number - Alias: ACCROLE5 - Business Definition: This is a unique identifier issued by the Australian Taxation Office (ATO) to entities who may not have a Tax File Number (TFN), or for entities interacting with the Tax Office in roles other than their Income Tax who may not have an Australian Business Number (ABN). - - - - - - - - - - - - Penalty and interest forecast date - Alias: ACCROLE6 - Report Guidance: The date to which the penalty and interest amounts will be calculated. - Business Definition: The date that the report is forecast to. - - - - - - - - Account identifier - Alias: ACCROLE7 - Report Guidance: Unique identifier for a taxpayer's account. -To search at the client level, do not provide client account details. - Business Definition: The identifier of the tax account as issued by the Australian Taxation Office. - - - - - - - - - - - - Account sequence number - Alias: ACCROLE8 - Report Guidance: The sequence number of the tax account. -To search at the client level, do not provide client account details. - Business Definition: The sequence number of the tax account. - - - - - - - - - - - - Pagination - - - - - \ No newline at end of file diff --git a/src/main/resources/samples/ato.accrole.0001.2017.list.01.00.xsd.xml b/src/main/resources/samples/ato.accrole.0001.2017.list.01.00.xsd.xml deleted file mode 100644 index 9a6dd9a..0000000 --- a/src/main/resources/samples/ato.accrole.0001.2017.list.01.00.xsd.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - 01234567 - 01234567890 - 0123456 - - - 012345678 - 01234567890 - 012345678 - 012345678901 - 2008-09-29 - 012345678901 - 200 - - - SGREM - - - 200 - 200 - - - \ No newline at end of file diff --git a/src/main/resources/samples/ato.accrole.0001.2017.list.response.01.00.xsd b/src/main/resources/samples/ato.accrole.0001.2017.list.response.01.00.xsd deleted file mode 100755 index 19bb84b..0000000 --- a/src/main/resources/samples/ato.accrole.0001.2017.list.response.01.00.xsd +++ /dev/null @@ -1,339 +0,0 @@ - - - - - - This schema was generated from a template. - Manual changes to this file will be overwritten if the schema is regenerated. - Generated on 2017-03-27T12:33:56, by ESR Version 1.57.0.0 using ESR Database - - - - - Information related to the entity - - - - - - - - - - - - Role Details - - - - - Role type - Alias: ACCROLE9 - Business Definition: This code identifies the tax role obligation or administrative requirement. - - - - - - - - Role name - Alias: ACCROLE15 - Business Definition: The name assigned to the tax role. - - - - - - - - Effective role start date - Alias: ACCROLE16 - Business Definition: The start date of a tax role - - - - - - - - Effective role end date - Alias: ACCROLE17 - Business Definition: The end date of a tax role - - - - - - - - Role start date - Alias: ACCROLE18 - Business Definition: The effective date of the tax role registration. - Business Guidance: This is the date on which the client first had an active period for a tax role. - - - - - - - - Lodgement cycle - Alias: ACCROLE19 - Business Definition: This indicates how frequently a client is required to lodge. - Business Guidance: Valid values are: -Annually = Annually. -HalfYearly = HalfYearly. -Monthly = Monthly. -Quarterly = Quarterly. -Fortnightly = Fortnightly. -Large = BiWeekly, Weekly or Fortnightly. - - - - - - - - Accounting treatment name - Alias: ACCROLE20 - Business Definition: The accounting treatment identifies how an account or assessment is to be treated over a specified period. An accounting treatment is applied to an account or an assessment for a finite period of time, or it can be applied from a particular date onwards - Business Guidance: Some examples of accounting treatments include: concessional general interest charge, natural disasters and release from debt. - - - - - - - - Current role balance amount - Alias: ACCROLE21 - Business Definition: The balance of a tax role - - - - - - - - Due and payable amount - Alias: ACCROLE22 - Business Definition: This is the value, as at the relevant date, for the tax debt that is due. - - - - - - - - Total interest amount - Alias: ACCROLE23 - Business Definition: The estimated tax penalty and interest amounts to be debited. - - - - - - - - Financial year end date - Alias: ACCROLE24 - Business Definition: The month and day on which the entity's approved financial year ends. - Business Guidance: Provide in mm-dd format. - - - - - - - - Role non reporting - Alias: ACCROLE28 - Business Definition: This indicates whether the tax role is a non-reporting role due to the obligation being met another way - Business Guidance: Example: The group head entity is reporting the obligation for the entity. -A choice of TRUE/FALSE values. -true = a non-reporting role. -false = a reporting role. - - - - - - - - - - Pagination - - - - - Record limit - Alias: ACCROLE10 - Report Guidance: This is the value that specifies the number of client account records to be returned per page from the service. - Business Definition: This is the maximum number of records to be returned in a list of values. - - - - - - - - Record start number - Alias: ACCROLE11 - Report Guidance: The index of the first record to be returned. - Business Definition: This number represents the position of a record in a list of records. - - - - - - - - Total record count - Alias: ACCROLE25 - Business Definition: The number of records that are available for an interaction. - - - - - - - - - - Information related to the entity - - - - - Tax File Number - Alias: ACCROLE3 - Business Definition: A unique number issued by the Tax Office to individuals and organisations to identify their tax records. It increases the efficiency in administering tax and other Australian Government systems such as income support payments. It is also used as the identifier for clients' income tax roles. A Tax File Number (TFN) can be used externally only for communication with the Tax Office, either directly by the client, or by an external organisation that is required to collect and quote the client's TFN to the Tax Office. - - - - - - - - - - - - Australian Business Number - Alias: ACCROLE4 - Business Definition: A unique public identifier issued to all entities registered in the Australian Business Register (ABR), to be used in their dealings with government. Companies registered under the Corporations Law and business entities carrying on an enterprise in Australia are entitled to an ABN. - - - - - - - - - - Withholding Payer Number - Alias: ACCROLE59 - Business Definition: The Withholding Payer Number (WPN) is allocated to clients who have withholding obligations under Pay As You Go (PAYG) withholding but who do not have an Australian Business Number (ABN). Its primary purpose is for quotation on payment summaries issued to their employees. For example, private individuals not carrying on an enterprise employing a nanny or housekeeper, would be allocated a WPN. - Business Guidance: The Withholder Payer Number reported must belong to the payer named in this record. - - - - - - - - - - Australian Taxation Office Reference Number - Alias: ACCROLE5 - Business Definition: This is a unique identifier issued by the Australian Taxation Office (ATO) to entities who may not have a Tax File Number (TFN), or for entities interacting with the Tax Office in roles other than their Income Tax who may not have an Australian Business Number (ABN). - - - - - - - - Account identifier - Alias: ACCROLE7 - Report Guidance: Unique identifier for a taxpayer's account. - Business Definition: The identifier of the tax account as issued by the Australian Taxation Office. - - - - - - - - Account sequence number - Alias: ACCROLE8 - Business Definition: The sequence number of the tax account. - - - - - - - - Account type - Alias: ACCROLE12 - Business Definition: The code that represents the type of tax account. - - - - - - - - Account category - Alias: ACCROLE13 - Report Guidance: Valid values are: -Tax -Loan -Super -Excise - Business Definition: The code that represents the category of tax account type. - Business Guidance: Account types have been categorised into different groupings (e.g. Super, Tax and Loans) - - - - - - - - Penalty and interest forecast date - Alias: ACCROLE6 - Report Guidance: The date to which the system will calculate the estimated penalty and interest amount. - Business Definition: The date that the report is forecast to. - - - - - - - - Count of client accounts returned - Alias: ACCROLE14 - Report Guidance: This is the number of client role records returned in this transaction - Business Definition: The number of records included in an interaction. - Business Guidance: This is the number of records that are available to be returned in a list of values. - - - - - - - - Role Details - - - - - Pagination - - - - - \ No newline at end of file diff --git a/src/main/resources/samples/ato.accrole.0001.2017.list.response.01.00.xsd.xml b/src/main/resources/samples/ato.accrole.0001.2017.list.response.01.00.xsd.xml deleted file mode 100644 index dff840d..0000000 --- a/src/main/resources/samples/ato.accrole.0001.2017.list.response.01.00.xsd.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - 01234567 - 01234567890 - 01234567890 - string - string - 200 - string - string - 2008-09-29 - 200 - - - - string - string - 2014-09-19 - 2006-08-20+10:00 - 2009-05-16 - string - string - 1000.00 - 1000.00 - 1000.00 - --08-09+10:00 - false - - - - 200 - 200 - 200 - - - \ No newline at end of file