All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.anotheria.anosite.gen.asblogdata.data.ModuleASBlogData Maven / Gradle / Ivy

There is a newer version: 4.1.2
Show newest version
/**
 ********************************************************************************
 *** ModuleASBlogData.java                                                    ***
 *** generated by AnoSiteGenerator (ASG), Version: 2.6.3                      ***
 *** Copyright (C) 2005 - 2010 Anotheria.net, www.anotheria.net               ***
 *** All Rights Reserved.                                                     ***
 ********************************************************************************
 *** Don't edit this code, if you aren't sure                                 ***
 *** that you do exactly know what you are doing!                             ***
 *** It's better to invest time in the generator, as into the generated code. ***
 ********************************************************************************
 */

package net.anotheria.anosite.gen.asblogdata.data;

import net.anotheria.anodoc.data.Module;
import net.anotheria.anodoc.data.DocumentList;
import net.anotheria.anodoc.data.IDHolder;
import net.anotheria.anodoc.data.NoSuchDocumentListException;
import java.util.List;


public class ModuleASBlogData extends Module{


	public static final String MODULE_ID = "asblogdata";

	public static final String LIST_POST = "list_post";
	public static final String ID_HOLDER_POST = IDHolder.DOC_ID_HOLDER_PRE+"post";
	public static final String LIST_COMMENT = "list_comment";
	public static final String ID_HOLDER_COMMENT = IDHolder.DOC_ID_HOLDER_PRE+"comment";
	public static final String LIST_TAG = "list_tag";
	public static final String ID_HOLDER_TAG = IDHolder.DOC_ID_HOLDER_PRE+"tag";

	public ModuleASBlogData(){
		super(MODULE_ID);
	}

	@SuppressWarnings("unchecked")
	private DocumentList _getPosts(){
		try{
			return getList(LIST_POST);
		}catch(NoSuchDocumentListException e){
			return new DocumentList(LIST_POST);
		}
	}

	private void _updatePosts(DocumentList list){
		putList(list);
	}

	public List getPosts(){
		return _getPosts().getList();
	}

	public PostDocument getPost(String id){
		return _getPosts().getDocumentById(id);
	}

	public void updatePost(PostDocument post){
		DocumentList posts = _getPosts();
		posts.removeDocumentById(post.getId());
		post.setLastUpdateNow();
		post.setCallContextAuthor();
		posts.addDocument(post);
		_updatePosts(posts);
	}

	public void deletePost(String id){
		DocumentList entries = _getPosts();
		entries.removeDocumentById(id);
		_updatePosts(entries);
	}

	public PostDocument createPost(PostDocument post ){
		IDHolder idh = _getIdHolder(ID_HOLDER_POST);
		int id = idh.getNextIdInt();
		post.renameTo(""+id);
		putDocument(idh);

		DocumentList entries = _getPosts();
		post.setLastUpdateNow();
		post.setCallContextAuthor();
		entries.addDocument(post);
		_updatePosts(entries);
		return post;
	}

	public PostDocument importPost(PostDocument post ){
		IDHolder idh = _getIdHolder(ID_HOLDER_POST);
		idh.adjustTill(post.getId());
		putDocument(idh);

		DocumentList entries = _getPosts();
		post.setLastUpdateNow();
		post.setCallContextAuthor();
		entries.addDocument(post);
		_updatePosts(entries);
		return post;
	}


	@SuppressWarnings("unchecked")
	private DocumentList _getComments(){
		try{
			return getList(LIST_COMMENT);
		}catch(NoSuchDocumentListException e){
			return new DocumentList(LIST_COMMENT);
		}
	}

	private void _updateComments(DocumentList list){
		putList(list);
	}

	public List getComments(){
		return _getComments().getList();
	}

	public CommentDocument getComment(String id){
		return _getComments().getDocumentById(id);
	}

	public void updateComment(CommentDocument comment){
		DocumentList comments = _getComments();
		comments.removeDocumentById(comment.getId());
		comment.setLastUpdateNow();
		comment.setCallContextAuthor();
		comments.addDocument(comment);
		_updateComments(comments);
	}

	public void deleteComment(String id){
		DocumentList entries = _getComments();
		entries.removeDocumentById(id);
		_updateComments(entries);
	}

	public CommentDocument createComment(CommentDocument comment ){
		IDHolder idh = _getIdHolder(ID_HOLDER_COMMENT);
		int id = idh.getNextIdInt();
		comment.renameTo(""+id);
		putDocument(idh);

		DocumentList entries = _getComments();
		comment.setLastUpdateNow();
		comment.setCallContextAuthor();
		entries.addDocument(comment);
		_updateComments(entries);
		return comment;
	}

	public CommentDocument importComment(CommentDocument comment ){
		IDHolder idh = _getIdHolder(ID_HOLDER_COMMENT);
		idh.adjustTill(comment.getId());
		putDocument(idh);

		DocumentList entries = _getComments();
		comment.setLastUpdateNow();
		comment.setCallContextAuthor();
		entries.addDocument(comment);
		_updateComments(entries);
		return comment;
	}


	@SuppressWarnings("unchecked")
	private DocumentList _getTags(){
		try{
			return getList(LIST_TAG);
		}catch(NoSuchDocumentListException e){
			return new DocumentList(LIST_TAG);
		}
	}

	private void _updateTags(DocumentList list){
		putList(list);
	}

	public List getTags(){
		return _getTags().getList();
	}

	public TagDocument getTag(String id){
		return _getTags().getDocumentById(id);
	}

	public void updateTag(TagDocument tag){
		DocumentList tags = _getTags();
		tags.removeDocumentById(tag.getId());
		tag.setLastUpdateNow();
		tag.setCallContextAuthor();
		tags.addDocument(tag);
		_updateTags(tags);
	}

	public void deleteTag(String id){
		DocumentList entries = _getTags();
		entries.removeDocumentById(id);
		_updateTags(entries);
	}

	public TagDocument createTag(TagDocument tag ){
		IDHolder idh = _getIdHolder(ID_HOLDER_TAG);
		int id = idh.getNextIdInt();
		tag.renameTo(""+id);
		putDocument(idh);

		DocumentList entries = _getTags();
		tag.setLastUpdateNow();
		tag.setCallContextAuthor();
		entries.addDocument(tag);
		_updateTags(entries);
		return tag;
	}

	public TagDocument importTag(TagDocument tag ){
		IDHolder idh = _getIdHolder(ID_HOLDER_TAG);
		idh.adjustTill(tag.getId());
		putDocument(idh);

		DocumentList entries = _getTags();
		tag.setLastUpdateNow();
		tag.setCallContextAuthor();
		entries.addDocument(tag);
		_updateTags(entries);
		return tag;
	}


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy