Skip to content
Snippets Groups Projects
Commit df4ffe84 authored by Jeffrey Phillips Freeman's avatar Jeffrey Phillips Freeman :boom:
Browse files

feat: added graphdb models fr the world.

parent b512346e
No related branches found
No related tags found
No related merge requests found
/**
* Copyright 2017 - 2018 Syncleus, Inc.
*
* 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.syncleus.aethermud.storage.graphdb.model;
import com.google.common.collect.Sets;
import com.syncleus.aethermud.storage.graphdb.DataUtils;
import com.syncleus.ferma.annotations.Adjacency;
import com.syncleus.ferma.annotations.GraphElement;
import com.syncleus.ferma.ext.AbstractInterceptingVertexFrame;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.tinkerpop.gremlin.structure.Direction;
import com.syncleus.aethermud.world.model.RoomModelData;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
@GraphElement
public abstract class FloorModelData extends AbstractInterceptingVertexFrame {
@Adjacency(label = "roomModel", direction = Direction.OUT)
public abstract RoomModelData addRoomModelData(RoomModelData roomModels);
@Adjacency(label = "roomModel", direction = Direction.OUT)
public abstract void removeRoomModelData(RoomModelData stats);
@Adjacency(label = "roomModel", direction = Direction.OUT)
public abstract <N extends RoomModelData> Iterator<? extends N> getRoomModelDatasIterator(Class<? extends N> type);
public Set<RoomModelData> getRoomModelDatas() {
return Collections.unmodifiableSet(Sets.newHashSet(this.getRoomModelDatasIterator(RoomModelData.class)));
}
public void setRoomModelDatas(Set<RoomModelData> roomModels) {
DataUtils.setAllElements(roomModels, () -> this.getRoomModelDatasIterator(RoomModelData.class), roomModelData -> this.addRoomModelData(roomModelData), () -> {} );
}
public RoomModelData createRoomModelData() {
final RoomModelData roomModel = this.getGraph().addFramedVertex(RoomModelData.class);
this.addEffectData(roomModel);
return roomModel;
}
@Property("rawMatrixCsv")
public abstract String getRawMatrixCsv();
@Property("rawMatrixCsv")
public abstract void setRawMatrixCsv(String rawMatrixCsv);
@Property("name")
public abstract String getName();
@Property("name")
public abstract void setName(String name);
@Property("id")
public abstract Integer getId();
@Property("id")
public abstract void setId(Integer id);
public static void copyFloorModel(FloorModelData dest, FloorModel src) {
try {
PropertyUtils.copyProperties(dest, src);
for(RoomModelData data : dest.getRoomModelDatas())
data.remove();
if( src.getRoomModelDatas() != null )
for(RoomModelData roomModelData : src.getRoomModelDatas())
RoomModelData.copyFloorModel(dest.createRoomModelData(), roomModelData);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
throw new IllegalStateException("Could not copy properties", e);
}
}
public static FloorModel copyFloorModel(FloorModelData src) {
FloorModel retVal = new FloorModel();
try {
PropertyUtils.copyProperties(retVal, src);
Set<RoomModel> roomModels = new HashSet<>();
if( src.getRoomModelDatas() != null )
for(RoomModelData roomModelData : src.getRoomModelDatas())
roomModels.add(RoomModelData.copyRoomModel(roomModelData));
retVal.setRoomModels(Collections.unmodifiableSet(roomModels));
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
throw new IllegalStateException("Could not copy properties", e);
}
return retVal;
}
}
/**
* Copyright 2017 - 2018 Syncleus, Inc.
*
* 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.syncleus.aethermud.storage.graphdb.model;
import com.syncleus.aethermud.storage.graphdb.DataUtils;
import com.syncleus.ferma.annotations.GraphElement;
import com.syncleus.ferma.ext.AbstractInterceptingVertexFrame;
import org.apache.commons.beanutils.PropertyUtils;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import java.util.Set;
@GraphElement
public abstract class RoomModelData extends AbstractInterceptingVertexFrame {
@Property("areaNames")
public Set<String> getAreaNames();
@Property("areaNames")
public void setAreaNames(Set<String> areaNames);
@Property("floorId")
public int getFloorId();
@Property("floorId")
public void setFloorId(int floorId);
@Property("roomTags")
public Set<String> getRoomTags();
@Property("roomTags")
public void setRoomTags(Set<String> roomTags);
@Property("roomId")
public int getRoomId();
@Property("roomId")
public void setRoomId(int roomId);
@Property("roomDescription")
public String getRoomDescription();
@Property("roomDescription")
public void setRoomDescription(String roomDescription);
@Property("roomTitle")
public String getRoomTitle();
@Property("roomTitle")
public void setRoomTitle(String roomTitle);
@Property("enterExitNames")
public Map<String, String> getEnterExitNames();
@Property("enterExitNames")
public void setEnterExitNames(Map<String, String> enterExitNames);
@Property("notables")
public Map<String, String> getNotables();
@Property("notables")
public void setNotables(Map<String, String> notables);
public static void copyRoomModel(RoomModelData dest, RoomModel src) {
try {
PropertyUtils.copyProperties(dest, src);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
throw new IllegalStateException("Could not copy properties", e);
}
}
public static RoomModel copyRoomModel(RoomModelData src) {
RoomModel retVal = new RoomModel();
try {
PropertyUtils.copyProperties(retVal, src);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
throw new IllegalStateException("Could not copy properties", e);
}
return retVal;
}
}
/**
* Copyright 2017 - 2018 Syncleus, Inc.
*
* 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.syncleus.aethermud.storage.graphdb.model;
import com.google.common.collect.Sets;
import com.syncleus.aethermud.storage.graphdb.DataUtils;
import com.syncleus.ferma.annotations.Adjacency;
import com.syncleus.ferma.annotations.GraphElement;
import com.syncleus.ferma.ext.AbstractInterceptingVertexFrame;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.tinkerpop.gremlin.structure.Direction;
import com.syncleus.aethermud.world.model.FloorModelData;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
@GraphElement
public abstract class WorldModelData extends AbstractInterceptingVertexFrame {
@Adjacency(label = "floorModel", direction = Direction.OUT)
public abstract FloorModelData addFloorModelData(FloorModelData floorModels);
@Adjacency(label = "floorModel", direction = Direction.OUT)
public abstract void removeFloorModelData(FloorModelData stats);
@Adjacency(label = "floorModel", direction = Direction.OUT)
public abstract <N extends FloorModelData> Iterator<? extends N> getFloorModelDatasIterator(Class<? extends N> type);
public Set<FloorModelData> getFloorModelDatas() {
return Collections.unmodifiableSet(Sets.newHashSet(this.getFloorModelDatasIterator(FloorModelData.class)));
}
public void setFloorModelDatas(Set<FloorModelData> floorModels) {
DataUtils.setAllElements(floorModels, () -> this.getFloorModelDatasIterator(FloorModelData.class), floorModelData -> this.addFloorModelData(floorModelData), () -> {} );
}
public FloorModelData createFloorModelData() {
final FloorModelData floorModel = this.getGraph().addFramedVertex(FloorModelData.class);
this.addEffectData(floorModel);
return floorModel;
}
public static void copyWorldModel(WorldModelData dest, WorldModel src) {
try {
PropertyUtils.copyProperties(dest, src);
for(FloorModelData data : dest.getFloorModelDatas())
data.remove();
if( src.getFloorModelDatas() != null )
for(FloorModelData floorModelData : src.getFloorModelDatas())
FloorModelData.copyFloorModel(dest.createFloorModelData(), floorModelData);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
throw new IllegalStateException("Could not copy properties", e);
}
}
public static WorldModel copyWorldModel(WorldModelData src) {
WorldModel retVal = new WorldModel();
try {
PropertyUtils.copyProperties(retVal, src);
Set<FloorModel> floorModels = new HashSet<>();
if( src.getFloorModelDatas() != null )
for(FloorModelData floorModelData : src.getFloorModelDatas())
floorModels.add(FloorModelData.copyFloorModel(floorModelData));
retVal.setFloorModels(Collections.unmodifiableSet(floorModels));
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
throw new IllegalStateException("Could not copy properties", e);
}
return retVal;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment