Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Need suggestion to implement the requirement

 
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Please suggest implementation for attached requirement.

You can think of List<SG> where SG has List<Periods> , Period has IOPS

SG, Period are Database tables.

Class SG {
String name;
List<Periods> periods;
String capacity;

}

Class Period {
Integer period;
Integer myValue;

}

Requirement: Merge all SGs per period.

Rules : when period exists , use that period value for merge
If not , use available previous period value
If not , use available next period value

From the above input –

Merge of period 1 : period 1 of Template + Period 1 of BTP1 + Period 3 of BTP 2

Why Period 3 of BTP 2 in Merge of Period 1 ? - because Period 1 not available in BTP 2 and No previous for Period 1 available and available next period in BTP2 is Period 3

Merge of Period 2 : Period 1 of Template + Period 2 of BTP 1 + Period 3 of BTP 2
Merge of Period 3 : Period 1 of Template + Period 3 of BTP 1 + Period 3 of BTP 2
Merge of Period 4 : Period 1 of Template + Period 3 of BTP 1 + Period 4 of BTP 2
Merge of Period 5 : Period 1 of Template + Period 5 of BTP 1 + Period 4 of BTP 2

Merge myValue output :

Period 1 : 100 + 200 + 300
Period 2 : 100 + 500 + 300
Period 3 : 100 + 400 + 300
Period 4 : 100 + 400 + 700
Period 5 : 100 + 200 + 700

And merged storage group will have only 5 periods

Please let me know if you have any questions and let me know your suggestion on implementation.

Thanks
TemplateTable.JPG
[Thumbnail for TemplateTable.JPG]
 
Marshal
Posts: 76479
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is not at all clear. Do you wish to do something with those objects or are you simply asking about how to display them in a table?
 
Rithanya Laxmi
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The table is the source for us, based on the table data we need to frame the logic as mentioned in my thread. Please clarify how we can go about it?

Thanks.
 
Campbell Ritchie
Marshal
Posts: 76479
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, you want to get information out of a database table? I presume you know how to connect to a database?
 
Rithanya Laxmi
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ritchie, This is nothing to do with the DB connection, the table contains different scenarios, how we can handle the logic in core java for the scenarios I have mentioned :-

Requirement: Merge all SGs per period.

Rules : when period exists , use that period value for merge
If not , use available previous period value
If not , use available next period value

From the above input –

Merge of period 1 : period 1 of Template + Period 1 of BTP1 + Period 3 of BTP 2

Why Period 3 of BTP 2 in Merge of Period 1 ? - because Period 1 not available in BTP 2 and No previous for Period 1 available and available next period in BTP2 is Period 3

Merge of Period 2 : Period 1 of Template + Period 2 of BTP 1 + Period 3 of BTP 2
Merge of Period 3 : Period 1 of Template + Period 3 of BTP 1 + Period 3 of BTP 2
Merge of Period 4 : Period 1 of Template + Period 3 of BTP 1 + Period 4 of BTP 2
Merge of Period 5 : Period 1 of Template + Period 5 of BTP 1 + Period 4 of BTP 2

Merge myValue output :

Period 1 : 100 + 200 + 300
Period 2 : 100 + 500 + 300
Period 3 : 100 + 400 + 300
Period 4 : 100 + 400 + 700
Period 5 : 100 + 200 + 700

And merged storage group will have only 5 periods ?
 
Campbell Ritchie
Marshal
Posts: 76479
366
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How would you do that with pencil and paper?
 
reply
    Bookmark Topic Watch Topic
  • New Topic