Conversion of java.util.date in TimestampLTZ

HIE

How can I convert a java.util.date type oracle.jbo.domain.TimestampLTZ?

Vik

Since java.sql.Timestamp extended (i.e., "is a") java.util.Date, simply use the constructor Timestamp (java.sql.Timestamp):

// y is a java.util.Date

oracle.jbo.domain.TimestampLTZ x = new TimestampLTZ(y);

http://download.Oracle.com/docs/CD/B25221_05/Web.1013/b16006/Oracle/JBO/domain/timestamp.html#Timestamp_java_util_Date _

Tags: Java

Similar Questions

  • Convert a Java.util.date in Timestamp

    I have a date of type java.util.Date
    Date today = new Date();
    which is in the format Tue Jan 10 00:00:00 IST 2012

    I need to convert the format to insert it into the Oracle database below

    2012-01-17 00:00:00.0


    Java version: 1.5

    Can someone help me in this.

    Hello

    Why not try with SimpleDateFormat ?

    D.

  • java.util.Date

    Hello world

    I have a problem, I did some two dates (initial, final) OSTEOARTHRITIS calendars with two other date in the CO and the I am, but I have to add 2 years in both dates incoming page, how can I do this?
    I do something like this:

    OANLSServices service = pageContext.getOANLSServices ();
    java.util.Date initial1 = services.stringToDate (pageContext.getParameter ("txtDate1"));
    java.util.Date System1 = services.stringToDate (pageContext.getParameter ("txtDate2"));
    Rank of validation [] = getMyVO1 () .getAllRowsInRange ();
    for (int i = 0; validation.length; i ++) {}
    MyVORowImpl r = validation (MyVORowImpl);
    java.util.Date initial2 = toJavaDate (r.getDate1 ());
    java.util.Date definitif2 = toJavaDate (r.getDate2 ());

    If (initial2.after (System1 + 2 years) & & final.before (initial2 + 2 years)) {}
    a not so important as the comparation code
    }

    }

    private java.util.Date toJavaDate (oracle.jbo.domain.Date pJboDate)
    {
    return new Date (pJboDate.timestampValue () .getTime ());
    }

    I hope you can help me with it :(

    Have a nice
    Kind regards
    Mentor

    Published by: mentor on October 4, 2010 08:46

    Mentor

    You can try using the calendar API. Something like that

    Calendar cal = Calendar.getInstance();
    cal.setTime(your_date);  //Your_date is the date you want to set
    cal.add(Calendar.YEAR, 2)
    System.out.println("After 2 years: " + cal.getTime());
    

    I hope that helps!

    Thank you
    AJ

  • Question about the java.util.Date class.

    The book I read said, class Date represents a value int long since January 1, 1970.


    I created a class of Date like this


    long mesh = 2000L;
    d.setTime (st);
    System.out.println ("new time is =" + d.toString ());

    When the above code, ultimately she prints the date as follows.

    New schedule is = Wed Dec 31 16:00:02 PST 1969

    No idea why the printed date before 1970? I expect the date to be a value greater than 01, January 1970.

    Welcome to the forum!
    >
    The book I read said, class Date represents a value int long since January 1, 1970.

    I created a class of Date like this

    long mesh = 2000L;
    d.setTime (st);
    System.out.println ("new time is =" + d.toString ());

    When the above code, ultimately she prints the date as follows.

    New schedule is = Wed Dec 31 16:00:02 PST 1969

    No idea why the printed date before 1970? I expect the date to be a value greater than 01, January 1970.
    >
    Because of the way as the setTime method is defined. What time zone do you use?

    http://docs.Oracle.com/javase/1.5.0/docs/API/Java/SQL/date.html#SetTime (long)
    >
    setTime
    Public Sub setTime(long date) defines an object Date existing using time value given in milliseconds. If the value of milliseconds given contains time information, the driver will set the components at the time in the default time zone (zone of the Java virtual machine running the application) which corresponds to zero GMT.

  • java.lang.String cannot be cast as a java.util.Date when using validateDateRange

    I use Jdev 11.1.2.0.0

    I have a StartDate and EndDate attributes that are used to get the date range

    My requirement is to show an error if the conditon EndDate > = StartDate is not satisfied

    For this I made use of validateDateRange

    < af:inputDate value = "#{bindings." StartDate.inputValue}.

    label = "#{hcmmexicoreportsuiBundle.start_date} '"

    required = "#{bindings." StartDate.hints.mandatory}.

    columns = "#{bindings." StartDate.hints.displayWidth}.

    shortDesc = "#{bindings." StartDate.hints.tooltip}"id ="id2 ".

    partialTriggers = "sbr1 id3.

    Disabled = "#{HcmWeeklyInquiryBean.disableDates} '"

    autoSubmit = "true" >

    < f: validator binding = "#{bindings." StartDate.validator} "/ >"

    < af:convertDateTime pattern = "#{bindings." StartDate.format} "/ >"

    < / af:inputDate >

    < af:inputDate value = "#{bindings." EndDate.inputValue}.

    label = "#{hcmmexicoreportsuiBundle.END_DATE} '"

    required = "#{bindings." EndDate.hints.mandatory}.

    columns = "#{bindings." EndDate.hints.displayWidth}.

    shortDesc = "#{bindings." EndDate.hints.tooltip}"id ="id3 ".

    partialTriggers = "sbr1 id2.

    Disabled = "#{HcmWeeklyInquiryBean.disableDates} '"

    autoSubmit = "true" >

    < f: validator binding = "#{bindings." EndDate.validator} "/ >"

    < af:convertDateTime pattern = "#{bindings." EndDate.format} "/ >"

    < minimum af:validateDateTimeRange = ' #{bindings. " StartDate.inputValue}.

    messageDetailMinimum = "#{hcmmexicoreportsuiBundle.END_DATE_SHOULD_BE_ON_OR_AFTER}" / >

    In the View object:

    < ViewAttribute

    Name = "StartDate".

    IsSelected = "false".

    IsPersistent = "false".

    PrecisionRule = 'true '.

    Type = "Oracle.jbo.domain.date"

    ColumnType = "DATE".

    AliasName = 'VIEW_ATTR. '

    SQLType = 'DATE' >

    Properties of <>

    < SchemaBasedProperties >

    < FMT_FORMATTER

    ResId="hl.hcm.rpt.model.view.HcmWeeklyInquiryCriteriaVO.StartDate_FMT_FORMATTER"/ >

    < FMT_FORMAT

    ResId="hl.hcm.rpt.model.view.HcmWeeklyInquiryCriteriaVO.StartDate_FMT_FORMAT"/ >

    < CONTROLTYPE

    Value = "date" / >

    < / SchemaBasedProperties >

    < / properties >

    < / ViewAttribute >

    < ViewAttribute

    Name = "EndDate".

    IsSelected = "false".

    IsPersistent = "false".

    PrecisionRule = 'true '.

    Type = "Oracle.jbo.domain.date"

    ColumnType = "DATE".

    AliasName = 'VIEW_ATTR. '

    SQLType = 'DATE' >

    Properties of <>

    < SchemaBasedProperties >

    < FMT_FORMATTER

    ResId="hl.hcm.rpt.model.view.HcmWeeklyInquiryCriteriaVO.EndDate_FMT_FORMATTER"/ >

    < FMT_FORMAT

    ResId="hl.hcm.rpt.model.view.HcmWeeklyInquiryCriteriaVO.EndDate_FMT_FORMAT"/ >

    < CONTROLTYPE

    Value = "date" / >

    < / SchemaBasedProperties >

    < / properties >

    < / ViewAttribute >

    I don't know why this error occurs because the type is not string and Date

    Thank you

    ASHA

    Can u try this?

    Thank you

    Alisson

  • problem of java.util.Date

    Hi gurus,

    My requirement, that is to make a date validation, a process runs only between January 1 and 5, how can I retrieve the current year and place it in a two variables, so I can compare to the current day... I try to do this without success, when I ran the app shows me error, I am doing this with OFA, here is my code:

    OANLSServices service = pageContext.getOANLSServices ();
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/YYYY");
    Day dToday = new Date();
    String sToday = sdf.format (dToday);
    dToday = services.stringToDate (sToday);
    Date d1 = new Date();
    Date d2 = new Date();
    String s1 = sdf.format (d1);
    String s2 = (d2) sdf.format;
    D1 = services.stringToDate (s1);
    D2 = services.stringToDate (s2);
    D1. SetDate (1);
    D1.setMonth (1);
    D1.setYear (dToday.GetYear ());
    D2. SetDate (5);
    D2.setMonth (1);
    D2.setYear (dToday.GetYear ());
    If ((dToday.equals (d1) | dToday.after (d1)) & & (dToday.equals (d2): dToday.before (d2))) {}
    some instructions
    } else {}
    instructions of another
    }

    This seems to do the hard work of a simple problem. Why not just create a departure Date of 1 Jan 00:00 object, a last Date 5th Jan 23:59 object, then use Date methods to compare the Date of today with these two object?

  • Conversion problem of oracle.jbo.domain.Date in java.util.Calendar and oracle.jbo.domain.Timestamp to oracle.jbo.domain.Date

    Hello world

    Work with dates has been harder than I thought! Please take a look at the code; everything compiles, but it fails because I'm not cast properly. Any help would be appreciated.

    Imports are:

    import java.sql.SQLException;

    to import java.text.ParseException;

    import impossible;

    import java.util.Calendar;

    Import oracle.jbo.domain.Date;

    Import oracle.jbo.domain.Timestamp;

    Here is the method:

    public static Date (String sDate, int day, nextDay

    SimpleDateFormat String) {}

    Date result = null;

    java.util.Date date;

    If (sDate! = null) {}

    try {}

    System.out.println ("Try...");

    Calendar calendar = Calendar.GetInstance ();

    SimpleDateFormat dateFormat =

    new SimpleDateFormat (simpleDateFormat);

    calendar.setTime (dateFormat.parse (sDate));

    Calendar.Set (Calendar.DAY_OF_WEEK, date); day = Calendar.SUNDAY

    Calendar.Set (Calendar.HOUR_OF_DAY, 0);

    Calendar.Set (Calendar.MINUTE, 0);

    Calendar.Set (Calendar.SECOND, 0);

    Calendar.Add (Calendar.DATE, 7);

    dateFormat.format (calendar.getTime ());

    try {}

    System.out.println ("try (inside)... ») ;

    "System.out.println (" new Timestamp (calendar.getTime () .getTime ()) "):" +.

    new Timestamp (calendar.getTime () .getTime ()));

    result = new Date (Timestamp (calendar.getTime () .getTime ())) new; Code does not work here.

    return the result;

    } catch (SQLException e) {}

    System.out.println ("catch (SQLException e)... ») ;

    e.printStackTrace ();

    }

    Returns a null value.

    } catch (ParseException exception) e {}

    System.out.println ("catch exception e ParseException... ») ;

    e.printStackTrace ();

    }

    Returns a null value.

    }

    Returns a null value.

    }

    Here is the result:

    try...

    Try (inside)...

    new Timestamp (calendar.getTime () .getTime ())): 2013-12-29 00:00:00.0

    catch (SQLException e)...

    java.sql.SQLException: failed initialization

    to oracle.sql.DATE. < init > (DATE.java:237)

    to oracle.jbo.domain.Date. < init > (Date.java:378)

    James

    try to convert timestamp to jbo.date as

    java.sql.Timestamp datetime =newjava.sql.Timestamp(System.currentTimeMillis());

    oracle.jbo.domain.Date daTime =new  oracle.jbo.domain.Date(datetime);

  • Does not not for java.sql.Date sort field

    Hi Experts ADF,

    JDev version 11.1.1.7.0

    I use a POJO based datacontrol, who is dragged like a table on page JSFF. One of the field is a java.sql.Date data type in POJO.

    So for example in the table 4 values are there to this date field as

    2.2.2014

    3.2.2014

    31.1.2014

    to 31.12.2013

    So while sorting in ascending order, it should come as below

    to 31.12.2013

    31.1.2014

    2.2.2014

    3.2.2014

    And vice-versa.

    But if I click on sort it sorts by the first 2 digits only, and I'm under results for sorting (ascending)

    2.2.2014

    3.2.2014

    31.1.2014

    to 31.12.2013

    Please suggest on this. Thanks in advance.

    Thank you

    Animesh

    Hi This sorting has been solved by changing of java.util.Date.

    Yes his watch to the client as an outputText inside the table. Sorting option is there for af:column.

    Thank you

    Roy

  • Cannot convert abcd of the type class java.lang.String interface java.util.List

    Hello

    I get an error of "cannot convert the class type abcd java.lang.String interface java.util.List" where "abcd" is a string in a listbox.

    and my code is something like this

    < af:selectOneListbox id = "lstcatg" label = 'List of categories' partialTriggers = 'proud '.

    value = "#{viewScope.RegWoComp.lstboxcatg}" >

    < f: selectItems id = value="#{viewScope.RegWoComp.customList}"/ "lstselect1" >

    < / af:selectOneListbox >


    bean

    private list < String > lstboxcatg;

    {} public void setLstboxcatg (List < String > lstboxcatg)

    This.lstboxcatg = lstboxcatg;

    }

    public List < String > getLstboxcatg() {}

    Return lstboxcatg;

    }

    public BindingContainer {} getBindings()

    Return BindingContext.getCurrent () .getCurrentBindingsEntry ();

    }

    Private Sub button (ActionEvent actionEvent)
    {
    JUCtrlListBinding listBindings = (JUCtrlListBinding) getBindings () .get (lstboxcatg);
    Object [] str = listBindings.getSelectedValues ();

    for (int i = 0; i < str.length; i ++)

    {

    System.out.println (STR [i]);

    }
    }

    I tried to use this fact.

    object str = listBindings.getSelectedValue ();

    System.out.println (STR);

    and here, if I change the data type of lstBoxcatg

    private String lstboxcatg;

    {} public void setLstboxcatg (String lstboxcatg)

    This.lstboxcatg = lstboxcatg;

    }

    public String getLstboxcatg() {}

    Return lstboxcatg;

    }

    can I get a nullpointerexception on line object str = listBindings.getSelectedValue ();

    No you can use this code you don't use link layer

    remove this code. You will get the selected value in this string variable

    Just write this about you button action and verification.

    System.out.println (selectedVal);

    Ashish

  • java.lang.ClassCastException: java.util.ArrayList cannot be cast to oracle.adf.view.faces.bi.model.GeoMapDataModel

    Hello world

    LM l and map creation using table list as the data collection for the leaf theme of points to specify a given location. The problem l get here is that, after setting up the collection of data on the theme tab, the choice address and longtude & latitudes remain disabled. LM using JDeveloper 12 c last version & weblogic 12 c. When l run my lm project this error: java.lang.ClassCastException: java.util.ArrayList cannot be cast to oracle.adf.view.faces.bi.model.GeoMapDataModel. Here is the source code of my page and the Bean managed that define the ArrayList

    MapBean.pngPageSourceCode.png

    kdario Thanks for your comment, no. l didn't download the demo of component, but l did it right now. l use developer J 12 c to see how GeoMapDataModel is created .it will come back to you if any problem arises.

  • In general, is it better to use java.sql.Date and java.sql.Timestamp instead of oracle.jbo.domain.Date?

    Hello world

    During playback of Oracle ADF Real World Developer's Guide, I noticed the dates match occurring in JDeveloper is different from what is the list in the book. JDeveloper is failing to oracle.jbo.domain.Date, but according to the book:

    DATEjava.sql.DateDATE type is mapped to java.sql.Date if the column in the table is a no time didn't need information zone.
    DATEjava.sql.TimestampDATE type is mapped to java.sql.Timestamp if the column in the table has a component "time" and that the client needs to zone information.
    TIMESTAMPjava.sql.TimestampThe TIMESTAMP type is mapped to java.sql.Timestamp if nanosecond precision is used in the database.

    In general, is it better to use java.sql.Date and java.sql.Timestamp instead of oracle.jbo.domain.Date? Using java.sql.Date and java.sql.Timestamp could save me some headaches conversion date. And, is there a place in JDeveloper to display these maps? I looked around and didn't see anything.

    Thank you.

    James

    User, what version of jdev we are talking about?

    In GR 11, 1 material versions db types date and timestamp are mapped to types of domain data that represents a wrapper for the native data types. The reason was that the framework can work with the domain types regardless of the underlying data type.

    Since Oracle 11 GR 2 maps the types DB to java types (default selection, you can change it when you create a model project, you can set the Data Type Mapping). Once the pilot has business components define you cannot change this setting it would break existing components such as eo or vo.

    So if you are working wit 11 GR 1 subject, you must use the domain types, if you work with GR 11, 2 or 12 c, you can use the domain types, but it is recommended to use the java type mapping.

    Timo

  • Faulty decompression with java.util.zip

    Hello
    I want to use the java.util.zip classes to compress the contents of the files (BMP images) and later unpack for display. Strange thing is that the same method usihg some files decompress correctly, the other does not.
    I wrote the test code for compression/decompression of the contents of a file (input parameters are 'c leader ', compressed file is given the extension ".comp" which was released on decompression). Here are two images of test. Suite (compress the file & decompression the result):
    TestCompDecomp c A.bmp
    TestCompDecomp d A.bmp.comp... is OK
    but the same process with B.bmp leads to a corrupt image.
    package testcompdecomp;
    
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.util.zip.DataFormatException;
    import java.util.zip.Deflater;
    import java.util.zip.Inflater;
    
    public class TestCompDecomp {
    
         static class Compressor {
              // compresses byte array, returns compressed bytes in array
              public byte[] compress(byte[] bytesToCompress){          
                   Deflater compressor = new Deflater(java.util.zip.Deflater.BEST_COMPRESSION);
                   compressor.setInput(bytesToCompress);
                   compressor.finish();
                   byte[] bytesCompressed = new byte[2000000];
    
                   int numberOfBytesAfterCompression = compressor.deflate(bytesCompressed);
                   compressor.end();
                   byte[] returnValue = new byte[numberOfBytesAfterCompression];
                   System.arraycopy(     bytesCompressed, 0,     returnValue,     0, numberOfBytesAfterCompression);
                   return returnValue;
              }
    
              // decompresses byte array, returns decompressed bytes in array
              public byte[] decompress(byte[] bytesToDecompress) throws DataFormatException {
                   Inflater decompressor = new Inflater();
                   int numberOfBytesToDecompress = bytesToDecompress.length;
                   decompressor.setInput( bytesToDecompress, 0, numberOfBytesToDecompress);
                   int compressionFactorMaxLikely = 3;
                   int bufferSizeInBytes = numberOfBytesToDecompress * compressionFactorMaxLikely;
                   byte[] bytesDecompressed = new byte[bufferSizeInBytes];
    
                   int numberOfBytesAfterDecompression = decompressor.inflate(bytesDecompressed);          
                   decompressor.end();
                   byte[] returnValue = new byte[numberOfBytesAfterDecompression];
                   System.arraycopy( bytesDecompressed, 0, returnValue, 0, numberOfBytesAfterDecompression);     
                   return returnValue;
              }
         }
         
         public static void main(String[] args) throws IOException, DataFormatException {
              if (args.length < 2) {
                   System.out.format("usage: TestCompDecomp <command> <file>%n%n");
                   System.out.format("<commands>%n  c   compress file%n  d   decompress file%n");
                   System.exit(-1);
              }
              byte[] input = null;
              byte[] output = null;
    
              //     read file content into array
              File inputFile = new File(args[1]);
              try (InputStream stream = new FileInputStream(inputFile)) {
                   long length = inputFile.length();
                   input = new byte[(int)length];
                   int offset = 0, numRead = 0;
                   while (offset < input.length && numRead >= 0) {
                        numRead = stream.read(input, offset, input.length-offset);
                        offset += numRead;
                   }
              } catch (IOException e) {
                   System.err.println(args[1]+": read error");
                   System.exit(-1);
              }
              // process the file content
              Compressor compressor = new Compressor();
              switch (args[0]) {
                   case "c":     // compression
                        output = compressor.compress(input);
                        break;
                   case "d":     // decompression
                        output = compressor.decompress(input);
                        break;
                   default: ;
              }
              // write the processed bytes to tne output file
              FileOutputStream outFile = null;
              String outFileName = args[1];
              switch (args[0]) {
                   case "c":
                        outFileName += ".comp";
                        break;
                   case "d":
                        outFileName = outFileName.replace(".comp", "");
                        break;
              }
              try {
                   outFile = new FileOutputStream(outFileName);
                   outFile.write(output);
              } finally {
                   if (outFile != null)
                        outFile.close();
              }
         }
    }
    Any idea please?

    Quido

    Welcome to the forum!
    >
    I want to use the java.util.zip classes to compress the contents of the files (BMP images) and later unpack for display. Strange thing is that the same method usihg some files decompress correctly, the other does not.
    >
    That's pretty much what you should expect when you write code that has absolutely NO verification errors or parameter control at all.

    GIGO - Garbage In, Garbage Out.

    Your compression method uses an array of bytes for a parameter. This byte array can be any legal size.

    Then you HARD-CODE the size of the byte array target/tablet to 2 million bytes. You want to keep only the fingers crossed that the compressed size will fall into this buffer. And your method does not check for errors.

    What makes you think that an array of bytes in the entry that is 1 GB in size will compress in 2 million bytes?

    Then you make similar assumptions for the method to decompress; you ASSUME that the decompressed data size will be no more than three times the compressed size.

    int compressionFactorMaxLikely = 3;
    int bufferSizeInBytes = numberOfBytesToDecompress * compressionFactorMaxLikely;
    byte[] bytesDecompressed = new byte[bufferSizeInBytes];
    

    And you already know what's going to happen if your assumtions are wrong.

    If you want to learn how to write good code you can not make any assumptions as you do. If you make assumptions, you need to add code to validate that your assumptions are correct, check the length of the tables being passed and add the error handling so that you know when things are bad.

    The foregoing would be bad enough, but the biggest mistake you do is reinvent the wheel. You write custom code to implement features that Java already provides for you.

    The best solution to your problem is to simply create a zip file standard of your entry. ALWAYS, ALWAYS, ALWAYS start with the simplest solution that meets your needs.

    A solution of zip files:

    1. the uses out of the box functionality Java – you have to write code that interacts with the API classes
    2. you can read/write the files of any arbitrary size without having to allocate buffers of unknown size.
    3. has a very minimal overhead in the zip file for the central directory structure of input data that are necessary for a single file and zip.
    4 makes it easy to inspect the contents of the zip file, because the file can be opened with ANY zip utility.
    5. makes it easy test read and write functionality separately. Just use Winzip or another utility to create a zip of an example of BMP file and then test your code to see if you can decompress.
    6. you can only work with the flow of input/output instead of arrays of bytes.

    I suggest abandon you your current approach and implement a read/write zip utility that interfaces with your BMP files you need. Only if that is not your needs in the long run you must use a custom approach.

    There are many simple examples on the web that show how to create, read and write zip using Java files. And here are two:
    http://www.java2s.com/Tutorial/Java/0180__File/Createazipfile.htm
    http://www.java2s.com/Tutorial/Java/0180__File/Readzipfile.htm

  • ClassCastException: java.util.ArrayList cannot be cast to oracle.adf.view.f

    Hello

    I am currently check why I encounter this error in a line graph?

    Basically I have the managed bean
    public class TestMB
    {
      private List<Object[]> tabularData = new ArrayList<Object[]>();
    
      public void setTabularData(List<Object[]> tabularData)
      {
        this.tabularData = tabularData;
      }
    
      public List<Object[]> getTabularData()
      {
        
        return tabularData;
      }
    }
    In the code, I have this defined graphic line.
    <dvt:lineGraph id="lineGraph1" subType="LINE_VERT_ABS"
       emptyText="No Data To Display"
       value="#{backingBeanScope.TestMB.tabularData}"
       contentDelivery="immediate">
           <dvt:background>
              <dvt:specialEffects/>
           </dvt:background>
           <dvt:graphPlotArea/>
           <dvt:seriesSet>
              <dvt:series/>
           </dvt:seriesSet>
           <dvt:o1Axis/>
           <dvt:y1Axis/>
           <dvt:legendArea automaticPlacement="AP_NEVER"/>
    </dvt:lineGraph>
    But I continued to encounter this error.
    java.lang.ClassCastException: java.util.ArrayList cannot be cast to oracle.adf.view.faces.bi.model.DataModel
    My thought is that I would be able to display the emptytext attribute.

    JDeveloper 11.1.1.6

    Published by: Neliel Sep 9, 2012 23:51

    Neliel,

    You must link to the tabularData property and not to the value property.

    
           
              
           
           
           
              
           
           
           
           
    
    

    Arun-

  • Foglight v558 - Script fails with ScriptAbortException: script1001968: java.util.ConcurrentModificationException

    I have changed most of our rules through several Wssf and use a number of rule-level Variables. I got these variables through groovy scripts.

    Recently, I had to change a variable that appears in all the rules.

    This is the script that I have written so far:

    com.quest.nitro.service.sl.interfaces.rule import. *;

    def ruleInfo = "";
    def ruleSvc = server.get ("RuleService");
    def ruleList = ["DBSS - ADH Service status"];
    def varExp = "INST_NAME;
    def varText = "scope.parent_node.mon_instance_name";

    allRules = ruleSvc.getAllRules ();

    for (rule allRules) {}
    ruleName def = rule.getName ();
    def ruleCart = rule.getCartridgeName ();

    If (ruleList.contains (ruleName))
    If (ruleCart.equals ("DB_SQL_Server_UI")) {}
    def ExpressionSet = rule.getExpressions ();
    for (expression in ExpressionSet) {}
    If (expression.getName () .equals ("INST_NAME")) {}
    ExpressionSet.remove (expression);
    ruleInfo += "Removed variable $varExp of $ruleName \n";
    }

    }
    Add a new term
    ExpressionSet.add (rule.createExpression ("INST_NAME", varText));

    rule.setExpressions (ExpressionSet);
    ruleSvc.saveRule (rule);
    ruleInfo += "added $varExp variable $ruleName \n";
    }
    }

    Return ruleInfo;

    The part of the script that adds the variable work consistantly.  The part of the script removes it expresion of level rule fails most of the time with the following error:

    com.quest.nitro.service.sl.interfaces.scripting.ScriptAbortException: script1001968: java.util.ConcurrentModificationException

    I'm still fairly new to groovy and java script, but I gather that when I have to iterate over a collection that is changed in another thread, the iterator survey a java.util.ConcurrentModificationException.  I read that I should look somehow collection synchronization.  Before we go down this rabbit hole, I thought I would just ask here, how should I write this code then it work consistantly?

    This is due to brakes on an object. You can try to break your code into pieces. First of all try and get all the rules in a list that matches your criteria. Call it a refinedRuleList, and then iterate through this refinedRuleList for Expressions and remove them. This gives a try!

    Thank you

    #AJ Aslam

  • Java.util.Regex

    Hi all

    Can I use the java.util.regx of java in blackberry.

    Or I have to use the third-party evaluation library regular expressiong?

    Please someone answer but soon...

    Concerning

    You can check it out yourself:

    http://www.BlackBerry.com/developers/docs/6.0.0api/index.html

    (the second option, you must use a library)

Maybe you are looking for