Package com.scooterframework.orm.activerecord

Examples of com.scooterframework.orm.activerecord.ActiveRecord


     *
     * @param model model name
     * @return an ActiveRecord home instance of the model
     */
    protected ActiveRecord generateActiveRecordHomeInstance(String model) {
        ActiveRecord record = generateActiveRecordInstance(model);
        ActiveRecordUtil.setHomeInstance(record);
        return record;
    }
View Full Code Here


   
    /**
     * <tt>create</tt> method creates a new <tt>post</tt> record.
     */
    public String create() {
        ActiveRecord newPost = null;
        try {
            newPost = Post.newRecord();
            newPost.setData(params());
            newPost.save();
            flash("notice", "Post was successfully created.");
           
            return redirectTo(R.resourcePath("posts"));
        }
        catch(Exception ex) {
View Full Code Here

   
    /**
     * <tt>update</tt> method updates an existing <tt>post</tt> record.
     */
    public String update() {
        ActiveRecord post = null;
        try {
            post = Post.findById(p("id"));
            if (post != null) {
                post.setData(params());
                post.update();
                flash("notice", "Post was successfully updated.");
               
                return redirectTo(R.resourceRecordPath("posts", post));
            }
            else {
View Full Code Here

   
    /**
     * <tt>delete</tt> method deletes a <tt>post</tt> record.
     */
    public String delete() {
        ActiveRecord post = Post.findById(p("id"));
        if (post != null) {
            post.delete();
            flash("notice", "Post was successfully deleted.");
        }
        else {
            flash("notice", "There is no post record with primary key id as " + p("id") + ".");
        }
View Full Code Here

    public static String taggedContent(Object object, String field, String tag, String content, Map<String, String> properties) {
        String result = taggedContent(tag, content, properties);
       
        boolean errorOccurred = false;
        if (object != null && object instanceof ActiveRecord) {
            ActiveRecord ar = (ActiveRecord)object;
            if (!ar.isValid() && ar.getValidationResults().hasErrorOn(field)) {
                errorOccurred = true;
            }
        }
       
        if (errorOccurred) {
View Full Code Here

            !columnName.toLowerCase().endsWith("_id")) return columnName;
       
        String modelName = columnName.toLowerCase().substring(0, (columnName.length() - 3));
        String modelClassName = EnvConfig.getInstance().getModelClassName(modelName);
       
        ActiveRecord foreignRecordHome = ActiveRecordUtil.getHomeInstance(modelClassName, modelName, ActiveRecordUtil.DEFAULT_RECORD_CLASS);
        String[] pkNames = foreignRecordHome.getPrimaryKeyNames();
        if (pkNames == null || pkNames.length > 1 ||
            !"id".equalsIgnoreCase(pkNames[0])) return columnValue;
       
        String controllerName = WordUtil.pluralize(modelName);
       
View Full Code Here

            !columnName.toLowerCase().endsWith("_id")) return columnName;
       
        String modelName = columnName.toLowerCase().substring(0, (columnName.length() - 3));
        String modelClassName = EnvConfig.getInstance().getModelClassName(modelName);
       
        ActiveRecord foreignRecordHome = ActiveRecordUtil.getHomeInstance(modelClassName, modelName, ActiveRecordUtil.DEFAULT_RECORD_CLASS);
        String[] pkNames = foreignRecordHome.getPrimaryKeyNames();
        if (pkNames == null || pkNames.length > 1 ||
            !"id".equalsIgnoreCase(pkNames[0])) return columnValue;
       
        String resourceName = WordUtil.pluralize(modelName);
       
View Full Code Here

       
        for (String tagName : tagList) {
            if (currentTags != null && currentTags.contains(tagName)) continue;
            currentTags.add(tagName);
           
            ActiveRecord atag = new Tag();
            atag.setData("name=" + tagName);
            atag.create();
        }
    }
View Full Code Here

        List<ActiveRecord> tagRecords = new ArrayList<ActiveRecord>();
        for (String tagName : tagList) {
            if (currentTags.contains(tagName)) continue;
            currentTags.add(tagName);
           
            ActiveRecord atag = ActiveRecordUtil.getGateway(Tag.class).findFirst("name='" + tagName + "'");
            if (atag == null) {
                atag = new Tag();
                atag.setData("name=" + tagName);
                atag.create();
            }
            tagRecords.add(atag);
        }
       
        return record.allAssociated(Tag.class).add(tagRecords);
View Full Code Here

        List<String> tagList = Converters.convertStringToList(tags);
        if (tagList == null) return null;

        List<ActiveRecord> tagRecords = new ArrayList<ActiveRecord>();
        for (String tagName : tagList) {
            ActiveRecord atag = ActiveRecordUtil.getGateway(Tag.class).findFirst("name='" + tagName + "'");
            if (atag != null) {
                tagRecords.add(atag);
            }
        }
       
View Full Code Here

TOP

Related Classes of com.scooterframework.orm.activerecord.ActiveRecord

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.