Skip to content

Commit

Permalink
Added model implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
minborg committed Feb 4, 2015
1 parent 8b788e2 commit ce42272
Show file tree
Hide file tree
Showing 23 changed files with 571 additions and 42 deletions.
68 changes: 61 additions & 7 deletions src/main/java/com/speedment/codegen/TestConfigModel.java
@@ -1,6 +1,30 @@
/**
*
* Copyright (c) 2006-2015, Speedment, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); You may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.speedment.codegen;

import com.speedment.orm.config.model.ConfigEntity;
import com.speedment.orm.config.model.Dbms;
import com.speedment.orm.config.model.Project;
import com.speedment.orm.config.model.ProjectManager;
import com.speedment.orm.config.model.Schema;
import com.speedment.orm.config.model.Table;
import com.speedment.orm.platform.SpeedmentPlatform;
import com.speedment.util.Trees;
import java.util.stream.Collectors;

/**
*
Expand All @@ -10,12 +34,42 @@ public class TestConfigModel {

public static void main(String[] args) {


SpeedmentPlatform.getInstance().start();




final SpeedmentPlatform sp = SpeedmentPlatform.getInstance().start();

ProjectManager pm = sp.get(ProjectManager.class);

final Table table = Table.newInstance();

pm.add(Project.newInstance()
.setName("myProject")
.add(Dbms.newInstance()
.setName("someDatabase")
.add(Schema.newInstance()
.add(table)
)
)
);

final String s = pm.childrenStream().map(Project::getName).collect(Collectors.joining());
System.out.println(s);

System.out.println(Trees.traverse((ConfigEntity) pm, ConfigEntity::childrenStream, Trees.TraversalOrder.DEPTH_FIRST_PRE)
.map(ConfigEntity::getName)
.collect(Collectors.joining(", ", "[", "]")
));

final Schema schema = table.getParent().get();
final Dbms dbms = schema.getParent().get();
final Project project = dbms.getParent().get();

System.out.println(table.getRelativeName(pm));
System.out.println(table.getRelativeName(table));

System.out.println(pm.getName());
System.out.println(pm);

System.out.println(pm.childrenStream().count());

}

}
16 changes: 16 additions & 0 deletions src/main/java/com/speedment/orm/config/ConfigParameter.java
@@ -1,3 +1,19 @@
/**
*
* Copyright (c) 2006-2015, Speedment, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); You may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.speedment.orm.config;

/**
Expand Down
Expand Up @@ -39,7 +39,7 @@
* @author pemi
*/
public class DelegatorGroovyTest {

/*
// http://blog.andresteingress.com/2013/10/19/groovy-sneak-peak-the-delegatingscript-base-class/
public static void main(String[] args) throws CompilationFailedException, IOException {
Expand Down Expand Up @@ -299,5 +299,5 @@ public void postInject() {
}
}

*/
}
22 changes: 22 additions & 0 deletions src/main/java/com/speedment/orm/config/model/Column.java
@@ -1,9 +1,31 @@
/**
*
* Copyright (c) 2006-2015, Speedment, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); You may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.speedment.orm.config.model;

import com.speedment.orm.config.model.impl.ColumnImpl;

/**
*
* @author pemi
*/
public interface Column extends ConfigEntity<Column, Table, ConfigEntity<?, Column, ?>> {

public static Column newInstance() {
return new ColumnImpl();
}

}
16 changes: 16 additions & 0 deletions src/main/java/com/speedment/orm/config/model/ConfigEntity.java
@@ -1,3 +1,19 @@
/**
*
* Copyright (c) 2006-2015, Speedment, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); You may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.speedment.orm.config.model;

import com.speedment.orm.config.ConfigParameter;
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/com/speedment/orm/config/model/Dbms.java
@@ -1,9 +1,31 @@
/**
*
* Copyright (c) 2006-2015, Speedment, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); You may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.speedment.orm.config.model;

import com.speedment.orm.config.model.impl.DbmsImpl;

/**
*
* @author pemi
*/
public interface Dbms extends ConfigEntity<Dbms, Project, Schema> {

public static Dbms newInstance() {
return new DbmsImpl();
}

}
22 changes: 22 additions & 0 deletions src/main/java/com/speedment/orm/config/model/Index.java
@@ -1,9 +1,31 @@
/**
*
* Copyright (c) 2006-2015, Speedment, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); You may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.speedment.orm.config.model;

import com.speedment.orm.config.model.impl.IndexImpl;

/**
*
* @author pemi
*/
public interface Index extends ConfigEntity<Index, Table, ConfigEntity<?, Index, ?>> {

public static Index newInstance() {
return new IndexImpl();
}

}
21 changes: 21 additions & 0 deletions src/main/java/com/speedment/orm/config/model/Project.java
@@ -1,9 +1,30 @@
/**
*
* Copyright (c) 2006-2015, Speedment, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); You may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.speedment.orm.config.model;

import com.speedment.orm.config.model.impl.ProjectImpl;

/**
*
* @author pemi
*/
public interface Project extends ConfigEntity<Project, ProjectManager, Dbms> {

public static Project newInstance() {
return new ProjectImpl();
}
}
16 changes: 16 additions & 0 deletions src/main/java/com/speedment/orm/config/model/ProjectManager.java
@@ -1,3 +1,19 @@
/**
*
* Copyright (c) 2006-2015, Speedment, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); You may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.speedment.orm.config.model;

import com.speedment.orm.platform.Component;
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/com/speedment/orm/config/model/Schema.java
@@ -1,9 +1,31 @@
/**
*
* Copyright (c) 2006-2015, Speedment, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); You may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.speedment.orm.config.model;

import com.speedment.orm.config.model.impl.SchemaImpl;

/**
*
* @author pemi
*/
public interface Schema extends ConfigEntity<Schema, Dbms, Table> {

public static Schema newInstance() {
return new SchemaImpl();
}

}
22 changes: 22 additions & 0 deletions src/main/java/com/speedment/orm/config/model/Table.java
@@ -1,9 +1,31 @@
/**
*
* Copyright (c) 2006-2015, Speedment, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); You may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.speedment.orm.config.model;

import com.speedment.orm.config.model.impl.TableImpl;

/**
*
* @author pemi
*/
public interface Table extends ConfigEntity<Table, Schema, ConfigEntity<Table, ?, ?>> {

public static Table newInstance() {
return new TableImpl();
}

}

0 comments on commit ce42272

Please sign in to comment.