Package org.objectweb.speedo.sequence.lib

Examples of org.objectweb.speedo.sequence.lib.SpeedoSequence


                }
                sc.identity.sequenceName = se.value;
            }
        }
        //Create the sequence and register it
        SpeedoSequence seq = new JDOSequence();
        seq.name = sc.identity.sequenceName;
        seq.packageName = sc.moPackage.name;
        sc.moPackage.addSequence(seq);
        seq.datastoreName = sc.identity.sequenceName;
        seq.strategy = SpeedoSequence.NON_TRANSACTIONAL;
View Full Code Here


        for(Iterator classIt = sp.classes.values().iterator();classIt.hasNext();) {
            SpeedoClass clazz = (SpeedoClass) classIt.next();
            visitClass(clazz);
        }
        for (Iterator it = sp.sequences.values().iterator(); it.hasNext();) {
            SpeedoSequence sequence = (SpeedoSequence) it.next();
            visitSequence(sequence, sp);
        }
    }
View Full Code Here

     * Adds a sequence descriptor to the package descriptor.
     * If a sequence with the same name is already registered, nothing is done.
     * @param sequence the sequence to add.
     */
    public void addSequence(Object sequence){
      SpeedoSequence ss = (SpeedoSequence) sequence;
      //if the sequence is not already registered
      if (!sequences.containsKey(ss.name)) {
        //set the package name of the sequence
        ss.packageName = this.name;
        //add it to the list
View Full Code Here

  private void writeSequencesStatements() throws IOException {
    if (!sequences.isEmpty()) {
      PMapperRdb mapper = (PMapperRdb) msm.getPMapper();
      msm.getFileWriter().write("----------- SEQUENCES ---------\n");
      for (Iterator it = sequences.iterator(); it.hasNext();) {
        SpeedoSequence s = (SpeedoSequence) it.next();
        log("[DEBUG] Sequence " + s.datastoreName, Project.MSG_DEBUG);
        //just write the sql sequences
        if (s.datastoreName != null && s.datastoreName != "") {
          if (isGenerateDrop()) {
            msm.getFileWriter().write(
View Full Code Here

     * i.e "packageName.sequenceName".
     * @param sequence
     */
    public void addSequence(Object sequence) {
      if (sequence instanceof SpeedoSequence) {
        SpeedoSequence s = (SpeedoSequence) sequence;
        String fqName = (s.packageName == null )?(""):(s.packageName + ".") + s.name;
        //if the sequence is not already registered
        if (!sequenceName2sequences.containsKey(fqName)) {
          sequenceName2sequences.put(fqName, s);
          s.setSequenceManager(this);
        }
      }
    }
View Full Code Here

     * If no sequence is found, return null.
     * @param name the fully qualified name of the sequence,
     * i.e "packageName.sequenceName".
     */
    public SpeedoSequenceItf getSequence(String name) {
      SpeedoSequence s  = (SpeedoSequence) sequenceName2sequences.get(name);
      if (s != null) {
        try {
          initSequence(s);
        } catch (Exception e) {
          logger.log(BasicLevel.ERROR,
View Full Code Here

     * @throws PException
     */
    private void initSequence(Object sequence) throws PException {
      if (sequence instanceof SpeedoSequence) {
        try {
          SpeedoSequence s = (SpeedoSequence) sequence;
          //if the sequence is not a rdb sequence, use jf_longGen table
          if (s.datastoreName == null || s.datastoreName.equals("")) {
            if (longGenMgr == null) {
              //try to find the long gen manager in the registry
              synchronized (LongGenMgrRegistry.class) {
                longGenMgr = LongGenMgrRegistry.getLongGenMgr(mapper);
                if (longGenMgr == null) {
                  //if not already registered, create it
                  try {
                    longGenMgr = (LongGenMgr) Class.forName(getLongGenMgrName()).newInstance();
                  } catch (Exception e) {
                    throw new PException(e, "Cannot create LongGenMgr (probably a ClassLoader problem): " + getLongGenMgrName());
                  }
                  ((LongGenMgr) longGenMgr).init(mapper, PClassMapping.CREATE_STRUCTURE_IF_NEEDED);
                  //  and register it
                  LongGenMgrRegistry.registerLonGenMgr((LongGenMgr)longGenMgr);
                }
              } 
            }
            //create the long gen and associate it to the sequence
            s.setLongGen(((LongGenMgr) longGenMgr).getLongGen(s.getName()));
          } else {
            //else, use rdb_sequence_long_gen
            if (mapperRdb != null) {
              if (s.getLongGen() == null) {
                RdbSequenceLongGen rdbLongGen = new RdbSequenceLongGen(mapperRdb, s.datastoreName, false);
                if(s.start != null) {
                  rdbLongGen.setSequenceStart(s.start);
                }
                if(s.increment != null) {
                  rdbLongGen.setSequenceIncrement(s.increment);
                }
                if(s.cache != null) {
                  rdbLongGen.setSequenceStart(s.cache);
                }
                //create it
                Object conn = mapperRdb.getConnection();
                rdbLongGen.createSequence(conn);
                //and associate it to the sequence
                s.setLongGen(rdbLongGen);
                //close the connection
                mapperRdb.closeConnection(conn);
              }
            } else {
              throw new PException("Problem while init the sequence "
View Full Code Here

            logger.log(BasicLevel.WARN, "Umanaged sub node of "
                    + node.getNodeName() + ": " + unmanagedChildren.keySet());
        }
    }
    private void treatSequenceNode(Node seqNode, SpeedoPackage p) throws SpeedoException {
        SpeedoSequence s = new JDOSequence();
        Node n = null;
       
        //<!ATTLIST sequence name CDATA #REQUIRED>
        n = seqNode.getAttributes().getNamedItem("name");
        if (n == null)
View Full Code Here

            addJoinToClass(j, tableName, ((SpeedoField) mo).moClass);
        }
        return j;
    }
    private Object treatSequenceNode(Node node, Object mo) throws SpeedoException {
        SpeedoSequence s = new JDOSequence();
        Node n = null;
       
        //attribute name (compulsory)
        n = node.getAttributes().getNamedItem("name");
        if (n == null)
View Full Code Here

TOP

Related Classes of org.objectweb.speedo.sequence.lib.SpeedoSequence

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.