Package de.iritgo.aktera.persist

Examples of de.iritgo.aktera.persist.Persistent


      try
      {
        for (Configuration moduleConfig : moduleConfigs)
        {
          Persistent version = persistentFactory.create("aktera.Version");

          version.setField("type", "M");
          version.setField("name", moduleConfig.getAttribute("id", "unkown"));
          version.setField("version", moduleConfig.getChild("version").getValue("0.0.0"));
          version.add();
        }
      }
      catch (Exception x)
      {
        System.out.println(x.toString());
      }

      try
      {
        Model appInfo = (Model) req.getService(Model.ROLE, "aktera.app-info");

        Configuration[] appConfigs = appInfo.getConfiguration().getChildren("app");

        for (int i = 0; i < appConfigs.length; ++i)
        {
          Configuration appConfig = appConfigs[i];

          Persistent version = persistentFactory.create("aktera.Version");

          version.setField("type", "A");
          version.setField("name", appConfig.getAttribute("id", "unkown"));
          version.setField("version", appConfig.getChild("version").getValue("0.0.0"));
          version.add();
        }
      }
      catch (Exception x)
      {
        System.out.println(x.toString());
      }

      try
      {
        Persistent config = persistentFactory.create("aktera.SystemConfig");

        config.setField("category", "system");
        config.setField("name", "databaseCreated");
        config.setField("type", "B");
        config.setField("value", "true");

        if (! config.find())
        {
          config.add();
        }
      }
      catch (Exception x)
      {
        System.out.println(x.toString());
View Full Code Here


    for (Iterator ee = myMetaData.getDetailNames().iterator(); ee.hasNext();)
    {
      oneDet = (String) ee.next();

      Relation oneDetRelation = myMetaData.getRelation(oneDet);
      Persistent detailObj = null;

      try
      {
        detailObj = getFactory().create(oneDetRelation.getToPersistent());
      }
      catch (Exception e)
      {
        throw new PersistenceException("Unable to instantiate " + "detail db object '"
                + oneDetRelation.getToPersistent() + "'", e);
      }

      if (currentTransaction != null)
      {
        detailObj.setTransaction(currentTransaction);
      }

      if (! detailObj.allowed(Persistent.DELETE))
      {
        throw new PersistenceException("Delete of '" + oneDetRelation.getToPersistent() + "' not allowed");
      }

      Iterator stkLocal = oneDetRelation.getFromFields().iterator();
      Iterator stkForeign = oneDetRelation.getToFields().iterator();

      while (stkLocal.hasNext())
      {
        String localField = (String) stkLocal.next();
        String foreignField = (String) stkForeign.next();

        detailObj.setField(foreignField, getField(localField));
      }

      Persistent oneDetailObj = null;

      for (Iterator di = detailObj.query().iterator(); di.hasNext();)
      {
        oneDetailObj = (Persistent) di.next();
        oneDetailObj.setTransaction(currentTransaction);
        oneDetailObj.delete(true);
      }
    } /* for each detail */
  } /* deleteDetails */
 
View Full Code Here

      //return an empty map.
      return (Map) new HashMap();
    }

    //Ok, look for the lookup.
    Persistent lookupObj = getFactory().create(myMetaData.getSchemaName() + "." + lookupObjName);

    //Added by Santanu Dutt to build validValues Map from lookup object
    String lookUpField = myMetaData.getLookupField(fieldName);
    String lookUpFieldDisplay = myMetaData.getLookupFieldDisplay(fieldName);

    List lookups = lookupObj.query();

    vvMap = new HashMap();

    for (Iterator i = lookups.iterator(); i.hasNext();)
    {
      Persistent oneLookUp = (Persistent) i.next();

      vvMap.put(oneLookUp.getFieldString(lookUpField), oneLookUp.getFieldString(lookUpFieldDisplay));
    }

    return vvMap;
  } /* getValidValues(String) */
 
View Full Code Here

  /**
   * Create a new Persistent which participates in a transaction
   */
  public final Persistent create(String name, Transaction trx) throws PersistenceException
  {
    Persistent newPersistent = create(name);

    newPersistent.setTransaction(trx);

    return newPersistent;
  }
View Full Code Here

    if (log.isDebugEnabled())
    {
      log.debug("Populating default data for '" + persistentName + "'");
    }

    Persistent p = null;

    try
    {
      p = create(persistentName);

      Persistent checkExisting = create(persistentName);
      boolean nokeys = true;

      Configuration[] children = config.getChildren();

      // BUEROBYTE: Sort records by attribute 'id' (if present)
      Arrays.sort(children, new Comparator()
      {
        public int compare(Object o1, Object o2)
        {
          Configuration c1 = (Configuration) o1;
          Configuration c2 = (Configuration) o2;

          int id1 = 0;
          int id2 = 0;

          try
          {
            id1 = c1.getAttributeAsInteger("id");
          }
          catch (ConfigurationException x)
          {
          }

          try
          {
            id2 = c2.getAttributeAsInteger("id");
          }
          catch (ConfigurationException x)
          {
          }

          return id1 - id2;
        }
      });

      // BUEROBYTE
      Configuration oneChild = null;

      for (int j = 0; j < children.length; j++)
      {
        oneChild = children[j];

        if (! oneChild.getName().equals("record"))
        {
          throw new ConfigurationException("default-data element must contain only record elements");
        }

        p.clear();
        checkExisting.clear();

        String oneFieldName = null;

        for (Iterator names = pmd.getFieldNames().iterator(); names.hasNext();)
        {
          oneFieldName = (String) names.next();

          // BUEROBYTE: Sort records by attribute 'id' (if present)
          if (! pmd.getKeyFieldNames().contains(oneFieldName) && "id".equals(oneFieldName))
          {
            continue;
          }

          // BUEROBYTE
          String attribValue = null;

          if (pmd.getKeyFieldNames().contains(oneFieldName))
          {
            if (pmd.isAutoIncremented(oneFieldName))
            {
              attribValue = oneChild.getAttribute(oneFieldName, null);
            }
            else
            {
              attribValue = oneChild.getAttribute(oneFieldName);
            }

            if (attribValue != null)
            {
              checkExisting.setField(oneFieldName, processedAttribValue(attribValue));
              nokeys = false;
            }
          }
          else
          {
            attribValue = oneChild.getAttribute(oneFieldName, null);
          }

          p.setField(oneFieldName, processedAttribValue(attribValue));
        }

        if (nokeys)
        {
          if (! p.find())
          {
            if (log.isDebugEnabled())
            {
              log.debug("No existing record for " + p.toString() + ", adding");
            }

            p.add();
          }
          else
          {
            if (log.isDebugEnabled())
            {
              log.debug("Existing record for " + p.toString());
            }
          }
        }
        else if (! checkExisting.find())
        {
          if (log.isDebugEnabled())
          {
            log.debug("No existing record with key " + checkExisting.toString() + "', adding");
          }

          p.add();
        }
        else
        {
          if (log.isDebugEnabled())
          {
            log.debug("Existing record with key " + checkExisting.toString());
          }
        }
      }
    }
    catch (PersistenceException pe)
View Full Code Here

      String schema = tok.nextToken();
      String table = tok.nextToken();
      String field = tok.nextToken();

      //Extract the value from the table
      Persistent p = create(schema + "." + table);

      tok = new StringTokenizer(lookupStr, "|");

      String f = null;
      String v = null;
      StringTokenizer t = null;

      for (int i = 0; i < tok.countTokens(); i++)
      {
        t = new StringTokenizer(tok.nextToken(), "=");
        f = t.nextToken();
        v = t.nextToken();
        p.setField(f, v);
      }

      if (p.find())
      {
        retValue = p.getFieldString(field);
      }
      else
      {
        throw new PersistenceException("Could not lookup indirect default-data value: " + retValue);
      }
View Full Code Here

    final Output oValues = res.createOutput(outputName);
    int idx = 0;

    for (final Iterator it = pValues.iterator(); it.hasNext(); idx++)
    {
      final Persistent pCurrent = (Persistent) it.next();

      log.debug("Processing Row: " + idx);

      final Output output = res.createOutput(Integer.toString(idx));
View Full Code Here

      for (int i = 0; i < configs.length; ++i)
      {
        Configuration config = configs[i];

        Persistent configEntry = persistentManager.create("aktera.PreferencesConfig");

        configEntry.setField("userId", userId);
        configEntry.setField("category", config.getAttribute("category"));
        configEntry.setField("name", config.getAttribute("name"));

        if (! configEntry.find())
        {
          configEntry.setField("type", config.getAttribute("type"));
          configEntry.setField("value", config.getAttribute("value", null));
          configEntry.setField("validValues", config.getAttribute("validValues", null));
          configEntry.add();
        }
      }
    }
    catch (PersistenceException x)
    {
View Full Code Here

        if (! config.getAttribute("category").equals(category) && ! config.getAttribute("name").equals(name))
        {
          continue;
        }

        Persistent configEntry = persistentManager.create("aktera.PreferencesConfig");

        configEntry.setField("userId", userId);
        configEntry.setField("category", config.getAttribute("category"));
        configEntry.setField("name", config.getAttribute("name"));

        if (! configEntry.find())
        {
          configEntry.setField("type", config.getAttribute("type"));
          configEntry.setField("value", config.getAttribute("value", null));
          configEntry.setField("validValues", config.getAttribute("validValues", null));
          configEntry.add();
        }
      }
    }
    catch (PersistenceException x)
    {
View Full Code Here

      }

      PersistentFactory persistentManager = (PersistentFactory) req.getService(PersistentFactory.ROLE, req
              .getDomain());

      Persistent keelUser = persistentManager.create("keel.user");

      keelUser.setField("uid", new Integer(uid));

      if (! keelUser.find())
      {
        ThreadedModel.sleep(3000);
        res.addError("notLoggedIn", "You are not logged in.");

        return res;
View Full Code Here

TOP

Related Classes of de.iritgo.aktera.persist.Persistent

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.