Time constraints on object state

I'm working on a project and I've come across a new thing I'm really new at. I've checked forums, but basicly, I don't know what to look for. I’ll try to explain it as simple as possible and give you an example of what we have to implement.
The project consists of builing a platform for a company to administrate contracts, transport requests etc. Each contract has, amongst other attributes like “contract period”, a ContractState, using the state pattern. States could be PROPOSED, SIGNED, EXPIRED, etc. We’re not using any kind of database for this, all contract objects are stored in a simple ArrayList.
So an example of what we’re trying to achieve is that when the time hits ‘creationdate + contractperiod’ for any contract, that contract’s state automatically changes to EXPIRED. On top of that, we have to be able to jump forwards and backwards in time during execution, for demonstration purposes. We’re thinking about making a clock, relative to the real time by adding or deducting a set period and maybe using an Observer pattern.
What is the best way to implement this?
Any tips could be of great help,
Thanks in advance.

Assuming this is just for homework, you could use:
public class Contract {
    public Contract(long creationDate, long contractPeriodInMillis) {}
    public getContractState(long currentTime) {
        if ((creationDate + contractPeriodInMillis) < currentTime) {
            return EXPIRED;
}I'm not sure I'd endorse that as a real-world solution without more thought than I want to put into it on a Friday afternoon. :-P

Similar Messages

  • Time Constraints for objects and relationships

    Hi,
    How to set up time constraints for objects and relationships under Org Management?
    Thanks in advance.

    Hi,
    If you need time constraint for subtype A002 then you have to define it over here.
    Usually for all standard objects this table gets populated by SAP. But in case you want something which is not there in this table and is as per the client requirement, you can create.
    regards
    guds

  • A dynamic table based on run-time created view object -- please help!

    Hello!
    I'm trying to create a dynamic table based on an run-time created view object. All go ok, but table binding component take the first view/iterator state and don't reflect changes they have. Please, take a look:
    1. At run-time the view is being replaced by new red-only one based on query in application module:
    getQueryView().remove();
    createViewObjectFromQueryStmt("QueryView", statement);
    2. Page definition file contains an iterator (using iterator or methodIterator - doesn't matter) binding and table, which binds to the iterator, like:
    <methodIterator id="distributeQuery1Iter" Binds="distributeQuery1.result"
    DataControl="QueryServiceDataControl" RangeSize="10"/>
    <table id="distributeQuery11" IterBinding="distributeQuery1Iter"/>
    3. The page code uses <af:table>. But, if I use table binding (it's right) like this:
    <af:table var="row" value="#{bindings.distributeQuery11.collectionModel}">
    <af:forEach items="#{bindings.distributeQuery11.attributeDefs}" var="def">
    the table will never changed (i.e. still show the first view instance).
    When I tried to use iterator binding directly (it's bad and cannot provide all needed features unlike CollectionModel from table binding) I saw that table works!
    (Code is somehing like:
    <af:table var="row" value="#{bindings.myIterator.allRowsInRange}">
    <af:forEach items="#{bindings.myIterator.attributeDefs}" var="def">
    Why the table binding do not reflect changes in iterator? Or should I use different approach?
    Thanks in advance!
    Ilya.

    I got it to work! I used a hybrid approach comprised of some of your code and some of Steve Muench's AcceessAppModuleInBackingBean example.
    In the setBindings method, I execute an app module method that redefines the query, then I used your code to delete and recreate bindings and iterator:
    public void setBindingContainer(DCBindingContainer bc) {
    this.bindingContainer = bc;
    rebuildVO();
    The rebuildVO() method looks like the code you provided in your example:
    private void rebuildVO() {
    DCDataControl dc;
    DispatchAppModule dApp;
    DCBindingContainer bc;
    DCIteratorBinding it;
    OperationBinding operationBinding;
    ViewObject vo;
    DCControlBinding cb;
    try {
    bc = getBindingContainer();
    dc = bc.findDataControl(DATACONTROL);
    dApp = (DispatchAppModule)dc.getDataProvider();
    // Execute App Module Method to rebuild VO based upon new SQL Statement.
    dApp.setDispatchViewSQL();
    vo = dApp.findViewObject(DYNAMIC_VIEW_NAME);
    it = bc.findIteratorBinding(DYNAMIC_VO_ITER_NAME);
    it.bindRowSetIterator(vo, true);
    // logger.info("Remove value binding...");
    cb = bc.findCtrlBinding(DYNAMIC_VIEW_NAME);
    cb.getDCIteratorBinding().removeValueBinding(cb);
    bc.removeControlBinding(cb);
    // logger.info("Creating new value binding...");
    FacesCtrlRangeBinding dynamicRangeBinding =
    new FacesCtrlRangeBinding(null,
    bc.findIteratorBinding(DYNAMIC_VO_ITER_NAME), null);
    // logger.info("Add control binding...");
    bc.addControlBinding(DYNAMIC_VIEW_NAME, dynamicRangeBinding);
    } catch (Exception e) {
    e.printStackTrace();
    And my App Module method that redefines the view object looks like this:
    public void setDispatchViewSQL() {
    String SQL =
    "begin ? := PK_BUsiNESS.F_GETDISPATCHVIEWSQL();end;";
    CallableStatement st = null;
    String ViewSQL = null;
    try {
    st = getDBTransaction().createCallableStatement(SQL,
    DBTransaction.DEFAULT);
    * Register the first bind parameter as our return value of type LONGVARCHAR
    st.registerOutParameter(1, OracleTypes.LONGVARCHAR);
    st.execute();
    ViewSQL = ((OracleCallableStatement) st).getString(1);
    findViewObject(DYNAMIC_VO_NAME).remove();
    ViewObject vo = createViewObjectFromQueryStmt(DYNAMIC_VO_NAME, ViewSQL);
    vo.executeQuery();
    } catch (SQLException s) {
    throw new JboException(s);
    } finally {
    try {
    st.close();
    } catch (SQLException s) {
    s.printStackTrace();
    When I run it I get my desired results. One thing I don't quite understand is why when the page is first rendered it shows the last set of records rather than the first. Now I have to figure out how to put navigation URLS in each of the table cells.
    Thanks for your help; I would not have gotten this far without it,
    Jeff

  • Object state not working if exported in PDF

    I'm working with Digital Publishing Suite and I have deeply appreciated the function "Object state". When used in connection with buttons and, eventually, the "Overlay Creator" it enables superb effects.
    I wonder about the fact that this helpful function does'nt work if the document is exported in PDF.
    Just in fact, at the moment, this feature works only with DPS, but I know that it is present since CS4, in times when DPS did'nt exist.
    Can you explain this?
    And when will be available in PDF exported documents?
    Thanks
    Lorenzo

    Hi Rahul,
    I have created the hyperlinks in the interactive (html) mode.
    While creating the hyperlink you just need to check one option "Use Complete URL path". This option will enable the hyperlink
    in the pdf mode too.
    FYI.. I am on BO XI 3.1
    Regards,
    Rohit

  • Testing Process for Gathering Single Object stats.

    Hello Oracle Experts,
    I work a critical system and due to some high stakes all and every change is very heavily scrutinized here whatever the level is. And one of such changes which is currently under scrutiny is gathering object stats for single objects. Just to give you a background its an Oracle eBusiness site so fnd_stats is used instead of usual dbms_stats and we've an inhouse job that depending on the staleness of the objects gather stats on them using FND_STATS. (RDBMS : 10.2.0.4 Apps Release 12i).
    Now, we've seen that occasionally it leaves some of the objects that should ideally be gathered so they need to be gathered individually and our senior technical management wants a process around it - for gathering this single object stats (I know!). I think I need to explicitly mention here that this need to gather stale object stats has emerged becs one of the plans has gone pretty poor (from 2 ms to 90 mins) and sql tuning task states that stats are stale and in our PROD copy env (where the issue exists) gathering stats reverts to original good plan! So we are not gathering just because they are stale but instead because that staleness is actually causing a realtime problem!
    Anyway, my point is that it has been gathered multiple times in the past on that object and also it might get gathered anytime by that automatic job (run nightly). There arguments are:
    i. There may be several hundred sql plans depending on that object and we never know how many, and to what, those plan change and it can change for worse causing unexpected issues in the service!
    ii. There may be related objects whose objects have gone stale as well (for example sales and inventory tables both see related amount of changes on column stock_level) and if we gather stats only on one of them and since those 2 cud be highly related (in queries etc.) that may mess up the join cardinality etc. messing up the plans etc.
    Now, you see they know Oracle as well !
    My Oracle (and optimizer knowledge) clearly suggests me that these arguments are baseless BUT want to keep an open mind. So my questions are :
    i. Do the risks highlighted above stand any ground or what probably do you think is there of happening any of the above?
    ii. Any other point that I can make to convince the management.
    iii. Or if those guys are right, Do you guys use or recommend any testing strategy/process that you can suggest to us pls?
    Another interesting point is that, they are not even very clear at this stage how they are gonna 'test' this whole thing as the 'cost' option like RAT (Real Application Testing) is out of question and developing an inhouse testing tool still need analyzing in terms of efforts, worth and reliability.
    In the end, Can I request top experts from the 'Oak Table' network to make a comment so that I can take their backings!? Well I am hoping here they'll back me up but that may not necessarily the case and I obviously want an honest expert assessment of the situation and not merely my backing.
    Thanks so much in advance!

    >
    I work a critical system and due to some high stakes all and every change is very heavily scrutinized here whatever the level is.
    Another interesting point is that, they are not even very clear at this stage how they are gonna 'test' this whole thing as the 'cost' option like RAT (Real Application Testing) is out of question and developing an inhouse testing tool still need analyzing in terms of efforts, worth and reliability.Unfortunately your management's opinion of their system as expressed in the first paragraph is not consistent with the opinion expressed in the second paragraph.
    Getting a stable strategy for statistics is not easy, requires careful analysis, and takes a lot of effort for complex systems.
    >
    In the end, Can I request top experts from the 'Oak Table' network to make a comment so that I can take their backings!? Well I am hoping here they'll back me up but that may not necessarily the case and I obviously want an honest expert assessment of the situation and not merely my backing.
    The ideal with stats collection is to do something simple to start with, and then build on the complex bits that are needed - something along the lines suggested by Dan Morgan works: a table driven approach to deal with the special cases which are usually: the extreme indexes, the flag columns, the time-based/sequential columns, the occasional histogram, and new partitions. Unfortunately you can't get from where you are to where you need to be without some risk (after all, you don't know which bits of your current strategy are causing problems).
    You may have to progress by letting mistakes happen - in other words, when some very bad plans show up, work out WHY they were bad (missing histogram, excess histogram, out of date high values) to work out the minimum necessary fix. Put a defensive measure in place (add it to the table of special cases) and run with it.
    As a direction to aim at - I avoid histograms unless really necessary, I like introducing function-based indexes where possible, and I'm perfectly happy to write small programs to fix columns stats (low/high/distinct) or index stats (clustering_factor/blevel/distinct_keys) and create static histograms.
    Remember that Oracle saves old statistics when you create new ones, so any new stats that cause problems can be reversed out very promptly.
    Regards
    Jonathan Lewis

  • Position to Cost Center Relationship with time constraint 1

    Hi,
    I have a situation wherein:
    1. There exists 2 records in PP01 with S-K relationship e.g. 01.01.2013 to 28.02.2013 and 01.03.2013 to 31.12.9999
    2. There is a requirement to create another S-K record with dates; 01.02.2013-28.02.2013 automatically delimiting the first record.
    Hence in all three records should exist
    But when i try creating the 3rd record with end date 28.03.2013, it gives an information message stating End Date corrected to maximum end date of 31.12.9999. Thereby over writing the previous record(2nd one)
    Do I need to change time constraint? Time constraint 1 should ideally allow this, as my records do not have gaps and exist at all times.
    Please guide me through.

    Hi Rohan,
    Please check the table V_T777ZVK and the time constraint between S and A011 it must be 02 as per the standard system.
    Then time constraint 2 means a maximum of one infotype record of the same type for the same object at the same time.
    So if you change then end date must be 31.12.9999.
    Regards,
    Mithun K

  • How to make a custom infotype field the time constraint 1?????

    Hello everyone I have this challenging question for gurus to answer it.
    In custom created infotype for OM Ii have that field called ZZJOBID. When infotype was created I assigned the time constraint 1 for that infotype. That time constraint was base on OBJID not on ZZJOBID. Now the problem I am encountering is when I assign the 2nd ZZJOBID  with time span 01011800-12319999 it overwrite the 1st assign ZZJOBID.
    for the requirement reason I have to use PO10( not po03). If I change the time constraint to 3 which let me have the multiple records but I am losing the delimit and other functionality which comes with time constraint 1.

    Suresh,
             you are wright when you say that ' Time Constraint is for the Infotype/Subtype record and cannot be based off a field.' The OM infotype runs on bases of Object such as Organizational Unit, Job, etc... The point I was trying to draw is I am looking for a way that allow me to work via TC PO10 which run on Organizational Unit along with different ZZJOBID (with same begda and endda, if needed).

  • Get a process variable's value to set a task's time constraints

    Hi,
    I want to have my task expiration times determined by a process variable (Data Object Artifact) that defines a task's "time to live".
    The problem is that I don't have visibility of the process variables inside the Time Constraint's Expression editor.
    Is there a way to get a value of a process variable inside a task without modifying the Web Dynpro associated with the task?
    Thank you,
    Pietro

    Hi Pietro,
    As the task is associated with the WD mapped to it, we will be able to access only the WD Interface controller context associated with it and also few other Task attributes.
    Regards,
    Unni

  • Deleting an Infotype with Time Constraint 1 - programatically

    Hi there,
    We have a few records (IT0008), that need to be deleted. Unfortunately, when we use PA30 to delete, it won't delete the record(s). (Displays the error msg. "Record has time constraint 1" ) But, when we use the Utilities option in PA30 and go thru', it appears to successfully delete the same.
    Now, could somebody pl. let us know how to go abt. doing the same programatically in ABAP ? I've tried looking at the FM's HR_MAINTAIN_MASTERDATA and HR_INFOTYPE_OPERATION (without much luck though....Although, SAP claims to have a documentation of these FM's, there is actually no proper docmn. at the Field level of these FMs)
    Moreover, the FM HR_MAINTAIN_MASTERDATA returns exactly the same error "Record has time constraint 1".
    Am a bit baffled as it is...
    Any help would be gratefully acknowledged and appreciated.
    Many thanks in anticipation,
    Kind Regards,
    RVS

    there is no function module to do forbidden actions.
    you only can do it with DELETE statement.
    select single dbtab from t777d into gv_dbtab where infty = p_infty.
    delete from (gv_dbtab) where pernr in p_pernr.
    But you will have to be very carefully. There are "blind" infotypes behind some "normal" infotypes you will have to care about (i.e. 0000 -> 0302).

  • No Time constraint for S 1001

    Dear Team,
    When I am trying to create a relationship to Position (S) or (C) Job, receiving a message as "There is no time constraint for S 1001". Unable to locate the exact error location in the customization.
    Could anyone know how to solve this. Not maintained any new objects or relationships.
    Thanks and Regards
    Team Member.

    Hi,
    Should have been standard for Position (S) and Job (C), but check table V_T777ZIT for IT1001 that the time constraint entry exists for the exact relationship you are trying to create.  If it does not exist, you will have to create the time constraint for that object and relationship. 
    IMG:  Personnel Management --> Organizational Management --> Basic Settings --> Data Model Enhancement --> Maintain Infotypes.  Select IT1001 and click on the folder on the left for Time Constraint.   Only one relationship at a time (Position described by one Job) - time constraint = 2.  More than one relationship at a time (Job describes many Positions) - time constraint = 3.
    Paul

  • DCIF - Time constraint 1

    Hi all
    The time constraint for the relationship that I am trying to update is set to 1.
    When the relationship start data is earlier than the object start date the DCIF changes the start date of the relationship to the start date of the object and updates the infotype with an information message stating 'Start date corrected to the minimum date allowed'.
    But if the relationship start date is later than the object start date then it gives an error message stating 'The validity of the record must match the validity of the object'.
    At the same time I can update the same relationship with the same start date as the error record(i.e the start date later than the object start date) from transaction PP01 and it allows me to save the record.
    Is there a particular reason why DCIF is meant to behave different to the standard transaction? has anyone else encountered this scenario?
    Thanks

    Hi Priti,
    What are time constraint
    1 no gaps and records are unique records are must  eg IT 0008
    2 Records may or may not be there if records are there they are unique eg IT 0019
    3 Records may or may not be there  gaps may be there Eg IT
    In which context you want to use time constraint , Time constraint classes are stored in T582A.
    Warm Regards,
    Kapil KAushal
    09833346985
    19:00to 23:00 IST

  • Hiding buttons in object states

    I am trying to do something that I feel is very simple but I'm losing my head working it out ;-) I have a simple page with multiple buttons that display a full page photo. It's all working fine, but no matter how I try and use layers, I simply cannot hide all my buttons. The attached images should explain what I am trying to do - there are buttons (the pins) which each trigger a full page photo using object states. Obviously I don't want those pins to show on my images. I feel like I am missing something very simple... thanks heaps for any assistance.

    Yeah, it's pretty simple:
    Build your layer 1 grouping pins and map together. Or make a single full page graphic showing map and pins. Put your buttons (transparent rectangles) above the graphic and attach a "go to state n" action to each.
    All photo layers should have a full page image with a "go to state 1" button above it.  Sometimes I use even a simpler method – I just convert the image itself  to a full page "go to state" button. I like the user experience: click anywhere on the page to go back to hotspots.
    Your document will have nothing outside the MSO, neither in background, nor above the MSO.
    The only tricky part is , that when you copy/paste buttons into object states, they loose their assigned actions. After completing the MSO you have to visit each button by selecting it in your layers panel to assign proper action.
    You can set the time of cross-fade between the states in the Folio Overlays panel.

  • Need help with Object States or Buttons?

    I currently work in InDesign to compile layouts and present design decks to clients. Our template includes an approval section (Not Approved, Revised, Approved) that we currently have as white/black bubbles that we change manually on each page. I've been trying to find a way to speed up this process. I know that in InDesign you can create buttons than you can then click on-off on your PDF - we used to do this but it is too time consuming (we have PDF's anywhere from 25-120 pages). I have been playing around with Object States, so we can quickly update the bubbles in InDesign itself as we work.
    Does anyone know of a way to change the state of multiple objects on multiple pages at the same time? (For example, if I want to change all pages to "Approved" at the same time - or if I only wanted to do some, but not all, of the pages.)
    Can anyone recommend any other InDesign tools that may be able to create a similar function for an "approval" stamp, but that still is done in InDesign (not in the PDF after exporting)?

    I was hoping that wouldn't be the only way. My have multiple master pages already, and not all pages will be "approved" at the same time. So we've run into issues with putting these on the masters as it gets easier to miss them.

  • Buttons in object states

    I am having some problems creating buttons in object states...I have a colored rectangle and a text box in each object state...I have selected the rectangle as the button to show the next state (there are only 2 states) and the second state leads back to the first one...
    but in some of the object states the text box does not appear?  if i don't have the second state as a button then it appears ok (but I can't return to the first state)
    any ideas? do i need to group each text and rectangle before placing it into the object state and subsequently making it a button?

    @Bob – it seems it is the only way to get something like a button control from one MSO to another.
    I stumbled over this just today so I had no time for testing.
    So duplicating an MSO seems to be an option…
    The example you see in the movie is a folio with PNG output saved as v20. Version 24 in this configuration is also doing fine.
    I think we have to explore the new possibilities this will give us.
    Though, I'm a little uneasy, because we leave the targets of the buttons inside the duplicated MSO in a very strange state:
    Uwe

  • Reconciling garbage collection, heap overview, and object stats

    First, both the JRockit RuntimeAnalyzer and Console are great tools. We use
    them extensively so thank you.
    I'm trying to reconcile the numbers in these three tabs.
    1. How do I reconcile the Runtime Analyzer and Console output?
    - The Heap overview tab in our application profile shows Heap Overview as
    83% free.
    - However, the Garbage Collection tab of the profile and Console shows the
    application as oscillating between 50 Meg and 200 Meg of heap used. That's
    25% (50Meg/200Meg) to 100%(200Meg/200Meg) used. How do I interpret the 83%
    vs. the 100%?
    I don't believe the 83% free, but I'm skeptical that we consume 150Meg of
    memory in 50 seconds.
    2. How do I reconcile the Object stats with the Garbage collection?
    - Take the top heap user at end of recording, character buffer. It's 22.8%
    of heap using 6,328 KB. If the heap is actually only 34Meg ( 17% of 200Meg.
    I get the 17% from the 83% free), then 22.8% makes sense.
    - So what's in the 200Meg of heap?
    I sent this recording to the JRA team if you want to look at it.
    Thanks
    Jeff

    I've never heard it put that way. Very interesting.
    "Johan Walles" <johan@spamalamadingdong> wrote in message
    news:41bf0be3@mail...
    Note that the time it takes for the garbage collector to do its thing
    grows with the amount of live data.
    What the garbage collector really does is more like retaining the live
    data than disposing of the garbage.
    Regards //Johan
    Jeff wrote:
    Staffan,
    Thanks - you clearly answered my questions. Now the follow-on questions:
    1. Is there a way to get insight into what the 'dead' data is composed
    of?
    2. Is this pattern of consuming 3x the live data in about a minute
    'typical' or a disaster in the making?
    I'm trying to get a sense of what a reasonable target of 'dead' data is.
    The system processes about a meg of data per second, including database
    writes.
    Thanks
    Jeff
    "sla" <[email protected]> wrote in message
    news:33533893.1102952170368.JavaMail.root@jserv5...
    Hi Jeff,
    I'll try to answer the questions.
    1) The Heap overview in the application profile is a snapshot of the heap
    at the end of a garbage collection. At this time only live data is still
    on the heap. So it looks like you have 17% of the heap filled with live
    data (and some overhead as seen in the Heap overview).
    In the garbage collection tab you can see the heap usage oscillating
    between 35-40MB and 200MB. The lower value is right after a garbage
    collection and the higher value is right before a garbage collection. The
    garbage collector clears out about 160MB of "dead" data from the heap.
    This is the amount of temporary objects that you created during the
    garbage collection cycles.
    2) The Object statistics are also taken right after a garbage collection.
    At this time there is 34M of live data on the heap and of these about 22%
    is taken up by character arrays (not unusual).
    At this time the rest of the 200MB heap is empty. It's been cleared of
    all temporary objects and is ready for allocation of new objects.
    I hope this answered your questions.
    Regards,
    /Staffan

Maybe you are looking for