Skip to main content
summaryrefslogtreecommitdiffstats
blob: 73f40ed90352d7dc1c194c2980668e1915e02877 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/**
 * <copyright>
 *
 * Copyright (c) 2005, 2006 Springsite BV (The Netherlands) and others
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   Martin Taal
 * </copyright>
 *
 * $Id: AccountingAction.java,v 1.3 2006/09/03 19:31:30 mtaal Exp $
 */

package org.eclipse.emf.teneo.test.emf.sample;

import java.io.InputStream;

import org.eclipse.emf.teneo.samples.emf.sample.accounting.Account;
import org.eclipse.emf.teneo.samples.emf.sample.accounting.AccountGroup;
import org.eclipse.emf.teneo.samples.emf.sample.accounting.Accounting;
import org.eclipse.emf.teneo.samples.emf.sample.accounting.AccountingFactory;
import org.eclipse.emf.teneo.samples.emf.sample.accounting.AccountingPackage;
import org.eclipse.emf.teneo.samples.emf.sample.accounting.JournalGroup;
import org.eclipse.emf.teneo.samples.emf.sample.accounting.Vat;
import org.eclipse.emf.teneo.test.AbstractTestAction;
import org.eclipse.emf.teneo.test.stores.TestStore;

/**
 * Performs a number of test actions on the catalog example. Create products, link a supplier, 
 * add to catalog, delete from catalog. 
 * 
 * @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
 * @version $Revision: 1.3 $ 
*/
public abstract class AccountingAction extends AbstractTestAction 
{
	public AccountingAction() 
	{ 
		super(AccountingPackage.eINSTANCE);
	}

	/** Creates a supplier, a product, relates then, saves and retrieves them again. */
	public void doAction(TestStore store)
	{
        final AccountingFactory factory = AccountingFactory.eINSTANCE;
    	{
	        store.beginTransaction();
	        
	        Accounting all = factory.createAccounting();
	        all.setName("Accounting Data");

	        Vat vat = factory.createVat();
	        vat.setName("19%");
	        vat.setRate(0.19f);
	        
	        Account account = factory.createBalanceAccount();
	        account.setName("Software Development Costs");
	        
	        AccountGroup accGroup = factory.createAccountGroup();
	        accGroup.setName("Activa");
	        accGroup.getAccount().add(account);
	        
	        JournalGroup yearJournal = factory.createJournalGroup();
	        yearJournal.setName("journalgroup");
	        
	        all.getVat().add(vat);
	        all.getJournalGroup().add(yearJournal);
	        all.getAccountGroup().add(accGroup);
	        
	        store.store(all);
    		store.commitTransaction();    		
    	}
		imTestExport(AccountingPackage.class.getResourceAsStream("import.xmi"), store);
	}
	
	/** Import/export, from and to */
	protected abstract void imTestExport(InputStream is, TestStore store);
}

Back to the top